home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / sosutl12.zip / bin / ps.cmd < prev    next >
OS/2 REXX Batch file  |  1993-10-18  |  1KB  |  36 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, and I still don't know whether
  8.  * this is the best or even the recommended method.  Why, oh why, IBM
  9.  * doesn't send decent manuals with OS/2?  Why, oh why, `rxqueue.exe' is
  10.  * not even mentioned in the online reference?
  11.  *
  12.  * 31-Mar-1993  v1.0: first usable AWK version.
  13.  * 2-Jun-1993   v2.0: translation to Perl.
  14.  * 3-Jul-1993   v3.0: whole process done from within Perl.
  15.  * 20-Aug-1993  v4.0: translation to REXX. Uses queues.
  16.  * 28-Aug-1993  v4.0a: Bug fix (see `ReadMe.1st' file).
  17.  */
  18.  
  19. "@echo off"
  20.  
  21. Say " PID  PPID   SID  PROCESS"
  22. "pstat /c |rxqueue"
  23. Do While Queued() <> 0
  24.     Pull line
  25.     If Words(line) == 8 & DataType(Word(line, 1), "X") == 1 Then Do
  26.         pid = Format(X2D(Word(line, 1)), 4)
  27.         ppid = Format(X2D(Word(line, 2)), 4)
  28.         sid = Format(X2D(Word(line, 3)), 4)
  29.  
  30.           /* Translate process names to lower case */
  31.         name = Translate(Word(line, 4), XRange("a", "z"), XRange("A", "Z"))
  32.  
  33.         Say pid"  "ppid"  "sid"  "name
  34.     End
  35. End
  36.