familyofcrowes has asked for the wisdom of the Perl Monks concerning the following question:
I have a script:
#!/usr/bin/perl @sa=split("\n",`vmstat`); @line=split(" ",$sa[1]); for ($i=0; $i <= @line; $i++) { if ( $line[$i] eq "us" ) { $j=$i; @stat=split(" ",$sa[2]); print "Message: CPU user time in percentage: $stat[$j] +\n"; print "Statistic: $stat[$j]\n"; exit 0; } } print "Message: ERROR: Can't find CPU user time (us) in output of -vms +tat- command. \n"; exit 1;
but I need to pull the info that is on a specific line. How do I do this? I have about 100 more of these I have to figure out as well, this just looked the easiest so far.
Thanks everyone for any help, I'm reading the tutorials as fast as I can....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: returning a specific value from a command
by toolic (Bishop) on Oct 28, 2011 at 15:36 UTC | |
|
Re: returning a specific value from a command
by Anonymous Monk on Oct 28, 2011 at 14:38 UTC | |
by pvaldes (Chaplain) on Oct 28, 2011 at 15:06 UTC | |
by familyofcrowes (Initiate) on Nov 02, 2011 at 17:32 UTC |