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

Re: ps in perl?

by apl (Monsignor)
on Dec 26, 2007 at 18:23 UTC ( [id://659095]=note: print w/replies, xml ) Need Help??


in reply to ps in perl?

Or, if you donm't like either of the previous solutions you could do

system( 'ps -ef >/tmp/ps.txt' );

After which you could load the contents of /tmp/ps.txt. It's not elegant, but it's simple and removes a dependency.

Replies are listed 'Best First'.
Re^2: ps in perl?
by dug (Chaplain) on Dec 26, 2007 at 19:03 UTC
    Perl provides you with a mechanism for reading the output of a system command, via backticks or the qx operator, which means you can eliminate the temporary file and process the output directly:
    foreach my $line ( qx[ps -ef] ) { # find the $line you're looking for }
    I've used the Proc::ProcessTable module with success, and second McDarren's recommendation, though.

    -- Douglas Hunter

Log In?
Username:
Password:

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

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

    No recent polls found