1

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!

  • 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

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. :)

  • 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
1

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`;
  • 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 '14 at 9:16

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