home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / sosutl11.zip / ps.cmd < prev    next >
OS/2 REXX Batch file  |  1993-08-20  |  1KB  |  34 lines

  1. /* ------
  2.  * ps.cmd (C) Tommi Nieminen 1993.
  3.  * ------
  4.  * Changes output coming from PStat to shorter and more readable format.
  5.  *
  6.  * NOTE: it took a long time until I found a method for piping something
  7.  * to REXX programs INSIDE a REXX program. Why, oh why, IBM doesn't send
  8.  * decent manuals with OS/2? Why, oh why, `rxqueue.exe' isn't documented
  9.  * in the online command reference guide?
  10.  *
  11.  * 31-Mar-1993  v1.0: first usable AWK version.
  12.  * 2-Jun-1993   v2.0: translation to Perl.
  13.  * 3-Jul-1993   v3.0: whole process done from within Perl.
  14.  * 20-Aug-1993  v4.0: translation to REXX. Uses queues.
  15.  */
  16.  
  17. "@echo off"
  18.  
  19. Say " PID  PPID   SID  PROCESS"
  20. "pstat /c |rxqueue"
  21. Do While Queued() <> 0
  22.     Pull line
  23.     If Words(line) == 8 & DataType(Word(line, 1)) == "NUM" Then Do
  24.         pid = Format(X2D(Word(line, 1)), 4)
  25.         ppid = Format(X2D(Word(line, 2)), 4)
  26.         sid = Format(X2D(Word(line, 3)), 4)
  27.  
  28.           /* Translate process names to lower case */
  29.         name = Translate(Word(line, 4), XRange("a", "z"), XRange("A", "Z"))
  30.  
  31.         Say pid"  "ppid"  "sid"  "name
  32.     End
  33. End
  34.