Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: File Handle qwerk?

by johngg (Canon)
on Apr 10, 2007 at 14:29 UTC ( [id://609156]=note: print w/replies, xml ) Need Help??


in reply to File Handle qwerk?

As Fletch points out, you might as well use Perl to pull out the line you want from the prtconf output. It is a good idea to use strict; and three argument opens.

use strict; use warnings; my $prtconfCmd = q{/usr/sbin/prtconf}; open my $prtconfFH, q{-|}, $prtconfCmd or die qq{fork: $prtconfCmd: $!\n}; my $memVal = q{}; while ( <$prtconfFH> ) { next unless m{^Mem.*?:\s+(\d+\s+\S+)}; $memVal = $1; last; } close $prtconfFH; print qq{Total memory is: $memVal\n};

I hope this is of use.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://609156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-18 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found