in reply to Re: perl function for 'ps' ?
in thread perl function for 'ps' ?
my $os = `uname`; chop $os; my $cmd = ( $os eq 'SunOS' ) ? '/usr/ucb -auxw' : '/bin/ps -ef'; my @psout = split /\n/, `$cmd`; my @hdr = split /\s+/, shift ( @psout ); my @aoh = (); while (1) { # load ps output into above array of hash... my $fldno = 0; my $tmp = {}; my @fld = ( split /\s+/,( shift( @psout ) || last )); $tmp -> { $hdr [ $fldno++ ] } = shift @fld for @hdr; $tmp -> { COMMAND } .= join ' ', @fld; push @aoh, $tmp; }
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: perl function for 'ps' ?
by nimdokk (Vicar) on Aug 14, 2006 at 14:29 UTC | |
|
Re^3: perl function for 'ps' ?
by gellyfish (Monsignor) on Aug 14, 2006 at 14:26 UTC | |
|