How to write long z/OS UNIX shell commands in BPXBATCH How to write long z/OS UNIX shell commands in BPXBATCH unix unix

How to write long z/OS UNIX shell commands in BPXBATCH


I'll take a stab at this. Using BPXBATCH, you want to issue a shell command. Here would be a simple example:

//TSTRADMB  JOB  MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M//BPXIT EXEC PGM=BPXBATCH,PARM='SH ls -l'//BPXPRINT DD SYSOUT=*//STDOUT DD SYSOUT=*//STDERR DD SYSOUT=*

This has the desired effect of writing the output of the shell command ls -l to stdout. But - what if it's a much longer string? Two ways you could go. One would be to write a wrapper script and call it from BPXBATCH (which is what I would do). The other would be to put the PARM across multiple lines, in which case you need to follow JCL rules for continuation (using a + in column 72 works), e.g.

//TSTRADMB  JOB  MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M//BPXIT EXEC PGM=BPXBATCH,PARM='SH ls -l "/u/tstradm/ThisIsAReallyLongD+//             irectoryThatCrossesMultipleLines"'//BPXPRINT DD SYSOUT=*//STDOUT DD SYSOUT=*//STDERR DD SYSOUT=*

The spacing with JCL is truly annoying - so you have to get it right. That + sign has to be in column 72 or you get a JCL error. The start of the next line of text begins in column 16. Start it late and you end up with blanks (which in this case would make a difference).


To pass long commands to BPXBATCH, use the STDPARM DD.

While it is possible to pass relatively long commands to BPXBATCH via the PARM parameter on the JCL EXEC statement by using JCL continuation rules, this method is still limited to 100 bytes.

A parameter file passed to BPXBATCH via STDPARM supports parameters (i.e the command) up to 64K in length. The parameter file can be a z/OS-Unix file, a traditional z/OS dataset, or in-stream in the JCL.

For example, place a long command (this sample command is 105 bytes):

SH ls -altr /listed_environments/cics/test/pickup/webs/test-portal-v01/src/assets/mixins | grep functions

into a z/OS-Unix file at /u/userid/stdparmfile

Then execute the command via BPXBATCH by utilizing STDPARM (PATHOPTS must be set to ORDONLY):

//USSCMD EXEC PGM=BPXBATCH//STDERR  DD SYSOUT=*//STDOUT  DD SYSOUT=*//STDPARM DD PATH='/u/userid/stdparmfile',PATHOPTS=ORDONLY/*//

Or place the same command into a traditional z/OS dataset (with a sufficient LRECL). Ensure that sequence numbers are removed from the dataset by issuing UNNUM and/or NUMBER OFF while in ISPF EDIT. Then similarly submit through JCL:

//USSCMD EXEC PGM=BPXBATCH//STDERR  DD SYSOUT=*//STDOUT  DD SYSOUT=*//STDPARM DD DISP=SHR,DSN=USERID.STDPARM.TEST/*//

In-stream submission on the STDPARM DD is a bit more restrictive, as a space character is assumed on each line-end. An in-stream command should be fine if it can be broken apart on space-char boundaries to fit within the 80-byte limit for JCL. The sample command we've used here would work like this:

//USSCMD EXEC PGM=BPXBATCH//STDERR  DD SYSOUT=*//STDOUT  DD SYSOUT=*//STDPARM DD *SH ls -altr/listed_environments/cics/test/pickup/webs/test-portal-v01/src/assets/mixins| grep functions/*//

But, a command that includes an uninterrupted string of text >80 bytes would likely present challenges for in-stream.

The z/OS 2.3 documentation for STDPARM can be found here:https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxa400/batstdparm.htm


In BPXBATCH, you actually want to use '+' as your continuation character for STDIN. BPXBATCH is a TSO command processor so it uses the TSO continuation character and not USS'