Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm fairly new to things and I've been writing a simple Perl script to poll a server for iostat -k -x data every few seconds using capture from Capture::Tiny

The script works, however the data being shown is being cut off. This doesn't happen if I normally do iostat -k -x

This is just to display the data n times in the space of a minute.

Script code, iostat -k -x output, output when poll script is used are here: http://pastebin.com/K1AnqskU

Any help would be appreciated!

share|improve this question

closed as off-topic by Falcon Momot, Andrew Schulman, MadHatter, kasperd, Sven Nov 19 at 3:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Falcon Momot, Andrew Schulman, MadHatter, kasperd, Sven
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Not sure but you just don't specify an interval value for iostat and let it repeat itself on its own? Perhaps iostat -k -x 2? –  Zoredache Sep 17 '10 at 20:29
    
Oh, and this may belong on stackoverflow instead of here. I suspect this has more to do with perl or the Capture::Tiny module, then anything to do with the system. –  Zoredache Sep 17 '10 at 20:31

2 Answers 2

Dude here who helped JP along with this a bit. We figured it out now.

Capture::Tiny was working fine and backticks did the same exact thing as Capture::Tiny.

The problem was simply that the dashes he used in the command line were unicode, so the shell simply ignored them. :)

share|improve this answer
1  
Been caught by that one before - copy\paste of commands from pdf's can be a killer. Good catch - have to admit that it took me a lot longer than 20 minutes to figure it out the first time it happened. –  Helvick Sep 17 '10 at 21:02

It seems, you have problems with "-" characters in your script.
If I copy-paste "iostat -k -x" from your example to my terminal, it gives truncated output. If I type the same by hand, the output is correct.

P.S. Since you ignore stderr output you could use

$stdout = `iostat –k –x`;
share|improve this answer
    
You're right, I get the same output doing "iostat k x" as the script, rather than if the "-" characters were being recognised –  Nemekh Sep 17 '10 at 20:42
    
and if we try in you code : system ("iostat", "-k", "-x"); instead of system ("iostat -k -x"); –  piaf Nov 18 at 9:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.