I'm not really how to ask this question the right way without being long winded, but will do my best! I need a script I'm writing to run pidstat -V inside of it and then to capture the output from it and use it to continue the script! I have tried so many variations, the only way I get no error readout is as follows
#!/usr/bin/perl
use strict;
use warnings;
my $cmd = "pidstat -V";
my @output = `$cmd`;
chomp @output;
if (@output eq 'sysstat version 11.2.0 (C) Sebastien Godard (sysstat <at> orange.fr)') {
etc etc etc.
The rest of the script runs fine when I use STDIN and the user defines their pidstat version, but when I use the above I get no errors and just a new line! I have come across different pidstat versions which give different readouts so have written my script to fit around this! I know I'm missing something but not sure what.
SOLVED!
It was painfully simple, all I needed was to add "2>&1 | sed -e '2d'" to the line:- "my $cmd = qx{pidstat -V};" and delete "(C) Sebastien Godard (sysstat orange.fr)" from my if statement.
Thanks all for the pointers, they really have helped.