Next Program Repair Shop 68

swswsw Problem

     Subject: alternatives to ps command
     Message-Id: <7fe42fcd.0109240201.7a6f98c2@posting.google.com>
     my $ps = `ps -fu$user`;
     # convert our scalar $ps into an array, break on \n
     my @aps = split /\n/, $ps;
     # loop each real processes
     foreach my $iaps (@aps) {
         # these are the only elements we require
         my ($stime, $time, $cmd);               
         # loop each possible process type
         foreach my $p (@processes) {
             # match the elements we require
             if ($iaps =~ m/^\s+\w+\s+\d+\s+\d+\s+\d+\s+([\d:]+)\s.+\s([\d:]+)\s(.+)
     $/) {
                 # save the values we have matched from above regex
                 $cmd   = $3; $stime = $1; $time  = $2;
                 ...

        for my $iaps (`ps -fu$user | tail +1`) {
          my ($user, $pid, $ppid, $cpu, $stime, $tty, $time, $cmd) = 
            split /\s+/, $iaps, 8;
          foreach my $p (@processes) {
            ... 

Next Copyright © 2006 M. J. Dominus