Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^3: Module to parse output from Unix ps command?

by hdb (Monsignor)
on Apr 11, 2013 at 11:32 UTC ( #1028121=note: print w/replies, xml ) Need Help??

in reply to Re^2: Module to parse output from Unix ps command?
in thread Module to parse output from Unix ps command?

Thanks for this comment, I never heard about this third argument. Here is the updated script:

use strict; use warnings; use Data::Dumper; my $command = "ps -f"; my $id = "PID"; my @ps =`$command`; $ps[0] =~ s/^\s*//; my @header = split /\s+/, shift @ps; my ($posid) = grep { $header[$_] eq $id } 0..$#header; die "$id: No such column!\n" unless defined( $posid ); splice @header, $posid, 1; my %psdata; while( @ps ) { my $row = shift @ps; chomp $row; $row =~ s/^\s*//; my @row = split /\s+/, $row, $#header+2; my $this_id = splice @row, $posid, 1; @{$psdata{$this_id}}{@header} = @row; } print Dumper( %psdata );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028121]
[ambrus]: choroba: cbstream alternates between the three direct IP addresses, without hostname, and switches to the next immediately at the first slowdown or error. this heuristic seems to help.
[choroba]: ambrus But pm-cb-g need sto stay logged in

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-10-24 11:22 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (288 votes). Check out past polls.