bluethundr has asked for the wisdom of the Perl Monks concerning the following question:

Hey guys

I ran into a new wrinkle with the script I am trying to write. For some reason, even tho I commented almost everything out this is the response I am getting from this script:

Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting. Incorrect options supplied, exiting.


And it goes on from there, that's just a snippet!

And here's the code that's causing it:

#!/usr/bin/perl use strict; use warnings; use IO::Pipe; use IO::Handle; use IO::File; my $system; my @systems = ( '3par-S400', '3par-E200' ); #open( MYFILE, '>>data.txt' ); #foreach my $system (@systems) { # my $output = run_command($system); # while (<$output>) { # next if (m/^$/); # next if (m/KBytes/); # next if (m/VVname/); # last if (m/^\-\-\-\-\-.*$/); # s/^ *//; # s/ +/\|/g; # print MYFILE $_; # } #} #close(MYFILE); #open( MYFILE, '<data.txt' ); #while (<MYFILE>) { # my $thisline = $_; # chomp($thisline); # my $gmetric="/usr/bin/gmetric"; ## This is what we grab and build the array ## 22:28:29|08/30/10|r/w|I/O|per|second|KBytes|per|sec|Svt|ms|IOSz|KB| ## VVname|Cur|Avg|Max|Cur|Avg|Max|Cur|Avg|Cur|Avg|Qlen ## This is the data we get per line # racprod_data03_500G_tpvv|t|674|674|674|6782|6782|6782|3.6|3.6|10.1|1 +0.1|2 # my @array= ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, + $kbMax, $svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen) = split /\|/, $ +thisline; # foreach @array { # print $_; # } #} #close(MYFILE); sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $space = " "; my $do_command = $protocol . $space . $ssh_flags . $space . $syste +m . $space . $command; my $cmd = IO::Pipe->new; $cmd->reader($do_command); return $cmd; }


It seems like the problem is with the IO::Pipe. What do I need to do to get this working, I must humbly and respectfully ask?

Thanks!

Replies are listed 'Best First'.
Re: Incorrect options supplied, exiting.
by Corion (Patriarch) on Sep 07, 2010 at 16:45 UTC

    Your code as posted does not reproduce the problem, because you never call run_command.

    My guess is that the command as constructed is wrong for some reason, and that makes the called program exit. I would print out the commands before they are run, and then check that the commands actually can run on their own, before blaming IO::Pipe.

    sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $space = " "; my $do_command = $protocol . $space . $ssh_flags . $space . $syste +m . $space . $command; print "Running [$do_command]\n"; my $cmd = IO::Pipe->new; $cmd->reader($do_command); return $cmd; }

    Also, why are you using IO::Pipe at all if you just want to run one command? You can use Perl to open a pipe-filehandle:

    sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $do_command = "$protocol $ssh_flags $system $command"; print "Running [$do_command]\n"; open my $fh, "$do_command |"; return $fh; }

    ... or you could just read the contents of the command directly:

    sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $do_command = "$protocol $ssh_flags $system $command"; print "Running [$do_command]\n"; my @results = `$do_command`; return @results }
Re: Incorrect options supplied, exiting.
by BrowserUk (Patriarch) on Sep 07, 2010 at 16:42 UTC

    Try printing out $do_command after you've built and then try invoking that exact command manually. Chances are your syntax is incorrect.

Re: Incorrect options supplied, exiting.
by psini (Deacon) on Sep 07, 2010 at 16:37 UTC

    Works for me. Are you sure that this is exactly the script that causes the error? On which platform did you execute it? Which perl/modules versions? Using which command?

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."