bluethundr has asked for the wisdom of the Perl Monks concerning the following question:
$gmetric $gmetric_conf "--name=VVname --value=$pVVname --type=uint32 +--units=name"; $gmetriC $gmetric_conf "--name=t --value=$t --type=uint32 --units +=t"; $gmetric $gmetric_conf "--name='I/O per second Cur' --value=$ioCu +r --type=uint32 --units=ioCur";
#!/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 $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 ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, +$svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen) = split /\|/, $thisline; print "$VVname $ioCur $ioAvg $ioMax $kbCur $kbAvg $kbMax + $svtCur $svtAvg $iokbCur $iokbAvg $Qlen\n"; } close(MYFILE); open( MYFILE, '<data.txt' ); while (<MYFILE>) { my $gmetric="/usr/bin/gmetric"; my $gmetric_conf="-c /etc/gmond.conf"; my $thisline = $_; chomp($thisline); my ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, +$svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen) = split /\|/, $thisline; $gmetric $gmetric_conf "--name=VVname --value=$pVVname --type=uin +t32 --units=name"; $gmetriC $gmetric_conf "--name=t --value=$t --type=uint32 --units +=t"; $gmetric $gmetric_conf "--name='I/O per second Cur' --value=$ioCu +r --type=uint32 --units=ioCur"; $gmetric $gmetric_conf "--name='I/O per second Avg' --value=$ioAv +g --type=uint32 --units=ioAvg"; } 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; }
[bluethundr@cc126-200:~/perl] $:./test-foo.pl Scalar found where operator expected at ./test-foo.pl line 42, near "$ +gmetric $gmetric_conf" (Missing operator before $gmetric_conf?) String found where operator expected at ./test-foo.pl line 42, near "$ +gmetric_conf "--name=VVname --value=$pVVname --type=uint32 --units=n +ame"" (Missing operator before "--name=VVname --value=$pVVname --type=u +int32 --units=name"?) Scalar found where operator expected at ./test-foo.pl line 43, near "$ +gmetriC $gmetric_conf" (Missing operator before $gmetric_conf?) String found where operator expected at ./test-foo.pl line 43, near "$ +gmetric_conf "--name=t --value=$t --type=uint32 --units=t"" (Missing operator before "--name=t --value=$t --type=uint32 --uni +ts=t"?) Scalar found where operator expected at ./test-foo.pl line 44, near "$ +gmetric $gmetric_conf" (Missing operator before $gmetric_conf?) String found where operator expected at ./test-foo.pl line 44, near "$ +gmetric_conf "--name='I/O per second Cur' --value=$ioCur --type=uint +32 --units=ioCur"" (Missing operator before "--name='I/O per second Cur' --value=$io +Cur --type=uint32 --units=ioCur"?) Scalar found where operator expected at ./test-foo.pl line 45, near "$ +gmetric $gmetric_conf" (Missing operator before $gmetric_conf?) String found where operator expected at ./test-foo.pl line 45, near "$ +gmetric_conf "--name='I/O per second Avg' --value=$ioAvg --type=uint +32 --units=ioAvg"" (Missing operator before "--name='I/O per second Avg' --value=$io +Avg --type=uint32 --units=ioAvg"?) syntax error at ./test-foo.pl line 42, near "$gmetric $gmetric_conf " Global symbol "$pVVname" requires explicit package name at ./test-foo. +pl line 42. Global symbol "$gmetriC" requires explicit package name at ./test-foo. +pl line 43. syntax error at ./test-foo.pl line 43, near "$gmetriC $gmetric_conf " syntax error at ./test-foo.pl line 44, near "$gmetric $gmetric_conf " syntax error at ./test-foo.pl line 45, near "$gmetric $gmetric_conf " Execution of ./test-foo.pl aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variable assignment error
by dasgar (Priest) on Sep 03, 2010 at 18:57 UTC | |
|
Re: variable assignment error
by Marshall (Canon) on Sep 03, 2010 at 19:24 UTC | |
|
Re: variable assignment error
by Crackers2 (Parson) on Sep 04, 2010 at 01:01 UTC | |
by choroba (Cardinal) on Sep 06, 2010 at 15:19 UTC |