mbayer has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to grep the total system memory of a Solaris box with the (prtconf | grep Memory) command, and then user Reg expressions to gather the RAM amount but I received the error: Could not open pipe for prtconf.
This should work, Any help would be appreciated.
O.K. -- syntax kills me again. Many thanks for the help.#!/usr/local/bin/perl -w use FileHandle; $memcmd=`/usr/sbin/prtconf | grep Memory`; $tmem = 0; $tmem_idle = new FileHandle ("$memcmd") || die "Could not open pipe fo +r prtconf: $!\n"; while (<$tmem_idle>) { if ( $_ =~ m/^.*\s+(\d+)\s+\d+$/ ) { $tmem = $1; } } close $tmem_idle; $tmem_busy = $tmem; # Just print the info! print "The total Memory amount is: $tmem_busy"; exit 0;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: File Handle qwerk?
by chargrill (Parson) on Apr 10, 2007 at 14:06 UTC | |
by ikegami (Patriarch) on Apr 10, 2007 at 14:42 UTC | |
by chargrill (Parson) on Apr 10, 2007 at 15:07 UTC | |
Re: File Handle qwerk?
by Fletch (Bishop) on Apr 10, 2007 at 14:18 UTC | |
Re: File Handle qwerk?
by johngg (Canon) on Apr 10, 2007 at 14:29 UTC |
Back to
Seekers of Perl Wisdom