Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trap output from bpxbatch or oshell

454 views
Skip to first unread message

James Melin

unread,
Jul 10, 2001, 5:24:08 PM7/10/01
to
Allocate stdout and stderr in the batch JCL?

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

Metz, Seymour

unread,
Jul 10, 2001, 6:18:29 PM7/10/01
to
command > file

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?

Robert Zenuk

unread,
Jul 10, 2001, 6:25:54 PM7/10/01
to
Here is an EXEC that does the equivalent of an outtrap/browse of a TSO
command. I call it USSCMD.

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

Jeremy C B Nicoll

unread,
Jul 10, 2001, 6:57:32 PM7/10/01
to
On 10 Jul, Robert Zenuk <Robz...@AOL.COM> wrote:
> Here is an EXEC that does the equivalent of an outtrap/browse of a TSO
> command. I call it USSCMD.

[snipped rexx]

Why do you libdef ispf libraries; what ispf services are you then using?

--
Jeremy C B Nicoll - my opinions are my own.

Robert Zenuk

unread,
Jul 10, 2001, 7:35:08 PM7/10/01
to
If I remember right, I went into one shop that had an older, minimal USS
configuration and had not installed the ISPF dialogs for general use and this
EXEC did not work. I'm thinking I ran into problems with the OBROWSE
service. I realize you have to address TSO for OBROWSE to work, so I'm not
sure now... After the one problem, I just left it in place to avoid the same
problem in the future. Periodic side jobs take you to strange places and
less than spotless environments...

I would remove the ACTIVATE and LIBDEFs when everything is in place. It is
obviously just extra overhead.

Thanks,
Robert Zenuk
robz...@aol.com

Metz, Seymour

unread,
Jul 11, 2001, 10:10:14 AM7/11/01
to
It will only work if you're running under ISPF.

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.

----------------------------------------------------------------------

Robert Zenuk

unread,
Jul 11, 2001, 3:16:41 PM7/11/01
to
Maybe I've missed the latest marketing/relabeling, but the OS/390 V2R10
manuals for the thing in MVS originally called Open Edition is called Unix
System Services. I regularly use the following manuals found at:

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

----------------------------------------------------------------------

Metz, Seymour

unread,
Jul 11, 2001, 3:49:57 PM7/11/01
to
AFAIK the current name is Unix Services, and IBM claims that USS was never
an official acronym.

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]

Bob Stark

unread,
Jul 12, 2001, 8:19:25 AM7/12/01
to
In addition to Jeremy's contribution, attached is another approach. It is
loosely based on the techniques in the OSHELL rexx exec. I developed it as
a demo for an AFCOM presentation. It has options for getting the output on
your screen or on the stack. It can handle issuing commands as superuser,
which is necessary for certain things, like getting a useful ps -eAf output.

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

Unixcmd

Bob Stark

unread,
Jul 13, 2001, 1:50:50 PM7/13/01
to
Note: This is a re-send from yesterday - my attachment with no extension
was mis-determined by many of your e-mail servers as a VBS program, and
rejected. I changed it to UNIXCMD.TXT, we'll see if that works any better.

TSO-REXX</blockquote>

UNIXCMD.txt

Metz, Seymour

unread,
Jul 13, 2001, 3:07:37 PM7/13/01
to
IF ABBREV('QUIT',TRANSLATE(shellcmd),1) THEN SIGNAL EXIT

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.

Sam Knutson

unread,
Jul 14, 2001, 10:23:32 AM7/14/01
to
With Bob's permission you can get his UNIXCMD exec here

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

0 new messages