home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / sosutl10.zip / PS.CMD < prev    next >
OS/2 REXX Batch file  |  1993-07-05  |  804b  |  30 lines

  1. extproc D:\usr\bin\UNIX\perl -x
  2.  
  3. #!perl
  4. # ------
  5. # ps.cmd (C) Tommi Nieminen 1993.
  6. # ------
  7. # Changes output coming from PStat to shorter and more readable format.
  8. # Requires Perl (tested with Perl 4.0.1.7 patchlevel 35).
  9. #
  10. # 31.03.1993    v1.0: first usable AWK version.
  11. # 02.06.1993    v2.0: translation to Perl.
  12. # 03.07.1993    v3.0: whole process done from within Perl.
  13.  
  14. print "PID   PPID  SID   PROCESS\n";
  15. open(PSTAT, "pstat /c |");
  16. while (<PSTAT>) {
  17.     @table = split(/ +/);
  18.     if ($#table == 8) {
  19.         $pid = hex($table[1]);
  20.         $ppid = hex($table[2]);
  21.         $sid = hex($table[3]);
  22.         $name = $table[4];
  23.  
  24.           # Convert name to lower case
  25.         $name =~ tr/A-Z/a-z/;
  26.  
  27.         printf("%04d  %04d  %04d  %s\n", $pid, $ppid, $sid, $name);
  28.     }
  29. }
  30.