home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / bit / listserv / cmspipl / 696 < prev    next >
Encoding:
Text File  |  1992-11-08  |  3.5 KB  |  127 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!stanford.edu!bcm!rice!newsfeed.rice.edu!wupost!darwin.sura.net!paladin.american.edu!auvm!CALVIN.GSFC.NASA.GOV!XRJDM
  3. X-Mailer: ELM [version 2.4beta PL13]
  4. Content-Type: text
  5. Content-Length: 2977
  6. Message-ID: <9211062043.AA01125@twinpeaks.gsfc.nasa.gov>
  7. Newsgroups: bit.listserv.cmspip-l
  8. Date:         Fri, 6 Nov 1992 15:43:14 -0500
  9. Sender:       VM/SP CMS Pipelines Discussion List <CMSPIP-L@MARIST.BITNET>
  10. From:         "(Joseph D. McMahon)" <xrjdm@CALVIN.GSFC.NASA.GOV>
  11. Subject:      Interfacing TSSO's OSCMD and Pipes
  12. Lines: 113
  13.  
  14. As the result of either inspiration or too much coffee :-), I've come up
  15. with a method of capturing output from TSSO's OSCMD command and routing
  16. it into a pipe. A bit of explanation would be useful here...
  17.  
  18. TSSO is an operations automation tool available for FREE on the CBT tape.
  19. It can intercept messages and issue commands in response to them; in
  20. addition, it can also issue TSO commands at the console, and provides
  21. an interface which allows TSO CLISTs (not REXX, just CLISTs) to issue
  22. system commands and capture the output.
  23.  
  24. The OSCMD command (the system command interface) provides a means of
  25. capturing command output into CLIST variables. It does not work properly
  26. with REXX variables or stems. However, there is a way atound this. The
  27. following CLIST and REXX filter provide an interface between OSCMD
  28. and Pipes.
  29.  
  30. ----
  31.  
  32. OS CLIST:
  33.  
  34. PROC 0 CMD()
  35.  
  36. SET CMDRESP=CLIST    /* point OSCMD's output to CLIST variables */
  37. SET CMDWAIT=5        /* Wait for 5 seconds for the command to execute */
  38. SET MAXCMDOUT=200    /* Capture up to 200 lines of output */
  39.  
  40. OSCMD &CMD           /* Issue the command */
  41.  
  42. SET I = 2            /* Start after command echo on line 1 */
  43.  
  44. DO WHILE &I <= &CMDOUT   /* Loop until all lines are processed */
  45.   SET OUTLIN = &STR(&&CMDOUT&I)    /* Get next line */
  46.   WRITE &OUTLIN          /* Send to output with TSO standard I/O */
  47.   SET I = &I + 1         /* Next line */
  48.   END                    /* of WHILE loop */
  49.  
  50. EXIT CODE(0)         /* Successful execution */
  51.  
  52. ----
  53.  
  54. TSOCMD command:
  55.  
  56. /* REXX - execute a TSO command and write its output to a file */
  57.  
  58. arg cmd
  59.  
  60. z = OUTTRAP(cmdout.,100)
  61. ADDRESS TSO cmd
  62. z = OUTTRAP(OFF)
  63.  
  64. ADDRESS TSO
  65.   "alloc f(TSOPIPOT) UNIT(TEMPDA) NEW SP(1) CYL REUSE"
  66.   "EXECIO * DISKW TSOPIPOT (STEM cmdout."
  67.  
  68. return
  69.  
  70. ----
  71.  
  72. TSOLIT Filter:
  73.  
  74. /* REXX - filter stage to execute a TSO command and send output into a pipe */
  75.  
  76. signal on error
  77.  
  78. arg x
  79.  
  80. "callpipe var x",
  81.      "|change ,,tsocmd ,",
  82.      "|command"
  83. "callpipe qsam tsopipot |*:"
  84.  
  85. exit
  86.  
  87. error: return RC*(RC^=12)
  88.  
  89. ----
  90.  
  91. A sample OSCMD-driven filter (TOSMTP):
  92.  
  93. /* REXX - Reroute a job to SMTP
  94.  
  95.    This REXX EXEC is a Pipes filter which treats the first word of the
  96.    primary input stream as a job number and issues a JES2 $TOJ command
  97.    to reroute the job to SMTP (locally). The command output is sent to
  98.    the primary output stream.
  99.  
  100.    Example: PIPE literal 1234|rexx tosmtp|console
  101.  
  102.  */
  103.  
  104. X = ''
  105.  
  106. do forever
  107.    if X = '' then 'readto X'
  108.    parse var X jobumber .
  109.    "callpipe var X",
  110.      "|spec /tsocmd os cmd('$TOJ/ 1 1-5 next /,OUTGRP=1.1.1,D=SMTP')/ next",
  111.      "|command"
  112.  
  113.    "callpipe qsam tsopipot|*:"
  114.    X = ''
  115.    end
  116.  
  117. error: return RC * (RC ^= 12)
  118.  
  119. ----
  120.  
  121. Thanks again to the original author of the TSOCMD filter (whose name I've
  122. misplaced). The only really cute little items are the trick in TOSMTP where
  123. the command is built by piecing it together with SPEC, and the trick of
  124. using a CLIST to force the output to come out in the standard manner.
  125.  
  126.  --- Joe M.
  127.