snippet from our inetd task.
//INETD EXEC PGM=BPXBATCH,ACCT=(9999,0557),
// PARM='PGM /usr/sbin/inetd -d /etc/inetd.conf'
//STDOUT DD PATH='/tmp/inetd.debug.stdout',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDERR DD PATH='/tmp/inetd.debug.stderr',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDENV DD DISP=SHR,DSN=SYTCB.DATA.TCPIP&SYSCHAR..INETD.ENVIRON
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX
seems like the obvious way. If you want it in a data set, you can use, e.g.,
OCOPY.
Shmuel (Seymour J.) Metz
> -----Original Message-----
> From: Lionel B Dyck [SMTP:Lionel...@KP.ORG]
> Sent: Tuesday, July 10, 2001 5:07 PM
>
> Does anyone know how to trap the results of a command issued under
> bpxbatch or oshell while running under classic OS/390?
I removed the calls to my standard error handling routines and replaced it
with 'says', hopefully I didn't break it.
If you already have the SYS1.BPX* libraries allocated, you can remove the
ALTLIB and LIBDEF code (I can't always count on them being in the logon
proc). If you named your SYS1.BPX* libraries something else, you will need
to tailor the dataset names.
/******************************* REXX ********************************/
/* Purpose: Execute USS commands from TSO and browse results */
/* */
/* Syntax: USSCMD cmd */
/* */
/* Parms: cmd - Any UNIX Systems Services Command */
/* */
/* Notes: */
/* */
/* Change Log */
/* Name Purpose date */
/* ------------- --------------------------------------- -------- */
/* R. Zenuk Initial creation Nov 2000 */
/* */
/*********************************************************************/
/* Standard entry */
/*********************************************************************/
parse upper source execenv . execname . execdsn .
/*********************************************************************/
/* Accept USS Command */
/*********************************************************************/
parse arg cmd
if cmd = '' then
do
say 'Command missing'
exit(8)
end
/*********************************************************************/
/* Command prefix */
/*********************************************************************/
cmdpfx = 'BPXBATCH SH'
/*********************************************************************/
/* Allocate the BPX libraries */
/*********************************************************************/
"ALLOC F(SYSUEXEC) DA('SYS1.SBPXEXEC') SHR REU"
"ALTLIB ACTIVATE USER(EXEC)"
address ISPEXEC
"LIBDEF ISPPLIB DATASET ID('SYS1.SBPXPENU')"
"LIBDEF ISPMLIB DATASET ID('SYS1.SBPXMENU')"
"LIBDEF ISPTLIB DATASET ID('SYS1.SBPXTENU')"
address TSO
/*********************************************************************/
/* Set STDOUT and STDERR file names */
/*********************************************************************/
stdout = '/tmp/'||userid()||'-bpxbatch-stdout-'||time('s')
stderr = '/tmp/'||userid()||'-bpxbatch-stderr-'||time('s')
/*********************************************************************/
/* Allocate STDOUT and STDERR for messages and errors */
/*********************************************************************/
"ALLOCATE FILE(STDOUT) PATH('"stdout"')",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC) PATHMODE(SIRWXU)"
ALLOCRC = RC
if ALLOCRC <> 0 then say 'STDOUT ALLOC Error RC='ALLOCRC
"ALLOCATE FILE(STDERR) PATH('"stderr"')",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC) PATHMODE(SIRWXU)"
ALLOCRC = RC
if ALLOCRC <> 0 then say 'STDERR ALLOC Error RC='ALLOCRC
/*********************************************************************/
/* Use BPXBATCH to execute the requested UNIX System Services CMD */
/*********************************************************************/
cmdpfx cmd
EXITRC = RC
/*********************************************************************/
/* If RC <> 0 BROWSE STDERR to determine the error */
/*********************************************************************/
if EXITRC <> 0 then
do
EXITRC = EXITRC / 256
zedlmsg = 'Error during execution of command:' cmd 'RC='EXITRC
viewfile = stderr
end
else
/*********************************************************************/
/* If RC=0 browse STDOUT to review the output */
/*********************************************************************/
do
zedlmsg = 'Successful execution of command:' cmdpfx cmd
viewfile = stdout
end
/*********************************************************************/
/* Display message and OBROWSE the correct output file */
/*********************************************************************/
address ISPEXEC
"SETMSG MSG(ISRZ000)"
address TSO
"OBROWSE" viewfile
/*********************************************************************/
/* Shutdown */
/*********************************************************************/
Shutdown: nop
/*********************************************************************/
/* Free and remove STDOUT and STDERR files */
/*********************************************************************/
"FREE F(STDOUT)"
FREERC = RC
if FREERC <> 0 then say 'STDOUT FREE Error RC='FREERC
"BPXBATCH SH rm -f" stdout
"FREE F(STDERR)"
FREERC = RC
if FREERC <> 0 then say 'STDERR FREE Error RC='FREERC
"BPXBATCH SH rm -f" stderr
/*********************************************************************/
/* Free the BPX libraries */
/*********************************************************************/
"ALTLIB DEACTIVATE USER(EXEC)"
"FREE F(SYSUEXEC)"
address ISPEXEC
"LIBDEF ISPPLIB"
"LIBDEF ISPMLIB"
"LIBDEF ISPTLIB"
exit EXITRC
Hope this helps,
Robert Zenuk
robz...@aol.com
[snipped rexx]
Why do you libdef ispf libraries; what ispf services are you then using?
--
Jeremy C B Nicoll - my opinions are my own.
I would remove the ACTIVATE and LIBDEFs when everything is in place. It is
obviously just extra overhead.
Thanks,
Robert Zenuk
robz...@aol.com
BTW, it's not USS (where are the acronym police?)
Shmuel (Seymour J.) Metz
> -----Original Message-----
> From: Robert Zenuk [SMTP:Robz...@AOL.COM]
> Sent: Tuesday, July 10, 2001 6:19 PM
>
> Here is an EXEC that does the equivalent of an outtrap/browse of a TSO
> command. I call it USSCMD.
----------------------------------------------------------------------
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/BPXSH0B1
OS/390 V2R10.0 Using REXX and OS/390 UNIX System Services
OS/390 V2R10.0 UNIX System Services Command Reference
In my mind, trapping the results of a command issued to the Unix Systems
Services side of OS/390 equated to calling my EXEC USSCMD.
For those interested in content, I realized my EXEC would not display the
output from USS REXX EXECs, so I made some changes and removed the LIBDEFs
and ALTLIB (thanks for pointing this out Jeremy).
This revision will not only capture the results of all non interactive USS
commands that display output (including scripts), but now will display the
output from non-interactive REXX EXECs that would normally be run from a
telnet session.
Another thing to point out, is this version actually shows how to ALLOCATE an
HFS file and EXECIO it (after thinking about it, I thought maybe Lionel's
original question may have actually been asking for this technique). This
isn't difficult, but requires a minimum set of required parameters on the
ALLOCATE statement. After that, EXECIO is pretty stock. I also attached
some sample JCL showing how to build BPXBATCH JCL with post processing steps
using IEBGENER to read HFS files.
/******************************* REXX ********************************/
/* Purpose: Execute USS commands from TSO and browse results */
/* */
/* Syntax: USSCMD cmd */
/* */
/* Parms: cmd - Any UNIX Systems Services Command */
/* */
/* Notes: */
/* */
/* Change Log */
/* Name Purpose date */
/* ------------- --------------------------------------- -------- */
/* R. Zenuk Initial creation Nov 2000 */
/* R. Zenuk Will display USS REXX output 07/11/01 */
/* */
/*********************************************************************/
/* Standard entry */
/*********************************************************************/
parse upper source @
parse upper source execenv . execname . execdsn .
/*********************************************************************/
/* Accept USS Command */
/*********************************************************************/
parse arg cmd
if cmd = '' then
do
say 'Command missing'
exit(8)
end
/*********************************************************************/
/* Command prefix */
/*********************************************************************/
cmdpfx = 'BPXBATCH SH'
/*********************************************************************/
/* Set STDOUT and STDERR file names */
/*********************************************************************/
stdout = '/tmp/'||userid()||'-bpxbatch-stdout-'||time('s')
stderr = '/tmp/'||userid()||'-bpxbatch-stderr-'||time('s')
/*********************************************************************/
/* Allocate STDOUT and STDERR for messages and errors */
/*********************************************************************/
"ALLOCATE FILE(STDOUT) PATH('"stdout"')",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC) PATHMODE(SIRWXU)"
ALLOCRC = RC
if ALLOCRC <> 0 then say 'STDOUT ALLOC Error RC='ALLOCRC
"ALLOCATE FILE(STDERR) PATH('"stderr"')",
"PATHOPTS(OWRONLY,OCREAT,OTRUNC) PATHMODE(SIRWXU)"
ALLOCRC = RC
if ALLOCRC <> 0 then say 'STDERR ALLOC Error RC='ALLOCRC
/*********************************************************************/
/* Use BPXBATCH to execute the requested UNIX System Services CMD */
/*********************************************************************/
cmdpfx cmd
EXITRC = RC / 256
/*********************************************************************/
/* If RC <> 0 BROWSE STDERR to determine the error (if not empty) */
/*********************************************************************/
if EXITRC <> 0 then
do
/*********************************************************************/
/* ALLOC STDERR as TESTERR with more options so EXECIO will work */
/*********************************************************************/
"ALLOC F(TESTERR) PATH('"stderr"') FILEDATA(TEXT)",
"PATHOPTS(ORDONLY) LRECL(136) BLKSIZE(1364)"
ALLOCRC = RC
if ALLOCRC <> 0 then say 'TESTERR ALLOC Error RC='ALLOCRC
/*********************************************************************/
/* Read all the lines of STDERR */
/*********************************************************************/
"EXECIO * DISKR TESTERR (STEM LINES. FINIS"
EXECIORC = RC
if EXECIORC <> 0 then say 'TESTERR EXECIO DISKR Error RC='EXECIORC
"FREE F(TESTERR)"
/*********************************************************************/
/* If STDERR is not empty, set the OBROWSE file to STDERR */
/*********************************************************************/
if lines.0 > 0 then
do
zedlmsg = 'Error during execution of command:' cmd 'RC='EXITRC
viewfile = stderr
end
else
/*********************************************************************/
/* If STDERR is empty and RC=255 use STDOUT (could be a REXX EXEC) */
/*********************************************************************/
do
if EXITRC = 255 then
zedlmsg = 'USS REXX EXEC or an error with:' cmd 'RC='EXITRC
viewfile = stdout
end
exit EXITRC
The sample JCL:
//XXXX JOB .............
//*******************************************************************
//* EXECUTE A USS COMMAND USING BPXBATCH *
//*******************************************************************
//USSCMD EXEC PGM=BPXBATCH,PARM='SH ps -ef'
//STDOUT DD PATH='/tmp/stdout.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
//STDERR DD PATH='/tmp/stderr.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
//*******************************************************************
//* PRINT STDOUT *
//*******************************************************************
// IF RC=0 THEN
//PRSTDOUT EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=Z
//SYSIN DD DUMMY
//SYSUT1 DD PATH='/tmp/stdout.out',FILEDATA=TEXT,PATHOPTS=ORDONLY,
// LRECL=120,BLKSIZE=1204,PATHDISP=(DELETE,DELETE)
//SYSUT2 DD SYSOUT=*
//*******************************************************************
//* PRINT STDERR *
//*******************************************************************
// ELSE
//PRSTDERR EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=Z
//SYSIN DD DUMMY
//SYSUT1 DD PATH='/tmp/stderr.out',FILEDATA=TEXT,PATHOPTS=ORDONLY,
// LRECL=120,BLKSIZE=1204,PATHDISP=(DELETE,DELETE)
//SYSUT2 DD SYSOUT=*
// ENDIF
Hope this helps,
Robert Zenuk
robz...@aol.com
----------------------------------------------------------------------
The REXX is still dependent on ISPF, because it uses OBROWSE. That's cool if
it is only intended for use under ISPF, but in that case the comments should
reflect the limitation.
Shmuel (Seymour J.) Metz
> -----Original Message-----
> From: Robert Zenuk [SMTP:Robz...@AOL.COM]
It IS a large attachment, my apologies for those not interested in this
topic, but it is self contained (all required subroutines are internal).
At 02:06 PM 7/10/01 -0700, Lionel B Dyck wrote:
>Does anyone know how to trap the results of a command issued under
>bpxbatch or oshell while running under classic OS/390?
>
>--------------------------------------------------------------------
>Lionel B. Dyck, Systems Software Lead
>Kaiser Permanente Information Technology
>25 N. Via Monte Ave
>Walnut Creek, Ca 94598
>
>Phone: (925) 926-5332
>Fax: (925) 926-5292
>
>E-Mail: Lionel...@kp.org
>Sametime: (use Lotus Notes address)
>AIM: lbdyck
TSO-REXX</blockquote>
Will recognize Q, QU, QUI and QUIT.
Shmuel (Seymour J.) Metz
> -----Original Message-----
> From: Bob Stark [SMTP:bst...@PROTECHPTS.COM]
> Sent: Friday, July 13, 2001 2:52 PM
>
> Note: This is my final attempt, at least for today, to re-send this REXX
> exec - my attempt to embed the exec into the message body exceeded the
> posting size limit. The attachment with no extension was mis-determined
> by
> many of your e-mail servers as a VBS program, and rejected. I am now
> trying
> to attach a zip file, we'll see if that works any better.
http://www.cbttape.org/ftp/adhoc/UNIXCMD.txt
if your email filters off attachments.
If you want to make something you might otherwise send as an attachment
available to the
list (weather or not you care to permenantly add it to the CBT Tape) just drop
me an email
directly at sknu...@landmark.com or sknu...@cbttape.org
I can usually make something available pretty quickly.
Thanks, Sam Knutson