DocBag

This Month's Topic

Running OMVS Commands in Batch

The BPXBATCH command can be used from TSO or batch to run an OMVS program or shell command. Here is an example of running OMVS commands in batch with the output going to SYSOUT: //RUNSHELL EXEC PGM=BPXBATCH,PARM='sh id' //STDOUT DD PATH='/tmp/bpxmsgs', // PATHOPTS=(OCREAT,OTRUNC,OWRONLY) //RUNSHELL EXEC PGM=BPXBATCH,PARM='sh ls -l' //STDOUT DD PATH='/tmp/bpxmsgs', // PATHOPTS=(OAPPEND,OWRONLY) //PRINT EXEC PGM=IKJEFT01,REGION=2000K,DYNAMNBR=20,TIME=(,10) //JESOUT DD SYSOUT=*,RECFM=V,LRECL=256 //TPSTDOUT DD PATH='/tmp/bpxmsgs', // PATHOPTS=ORDONLY //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * OCOPY INDD(TPSTDOUT) OUTDD(JESOUT) TEXT BPXBATCH PGM /bin/rm -f /tmp/bpxmsgs Two shell commands are run: An HFS file /tmp/bpxmsgs is allocated to standard output which receives the messages from each command. The PATHOPTS for the first step specify that this file will be created if it doesn't exist or overwritten if it does. The second step appends to this existing file. The final step copies the HFS file to SYSOUT and then deletes it. Note that BPXBATCH can be used from TSO in batch or invoked directly (PGM=).

If you are running V2R9 and up, you can use BPXBATSL instead of BPXBATCH to run a program. There is less execution overhead associated with BPXBATSL.

The TSO OSHELL EXEC allocates an HFS file, runs a shell command and then copies the result to SYSOUT. Here is an example:

//RUNOSH EXEC PGM=IKJEFT01,REGION=2M //SYSEXEC DD DSN=SYS1.SBPXEXEC,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * OSHELL id //RUNOSH EXEC PGM=IKJEFT01,REGION=2M //SYSEXEC DD DSN=SYS1.SBPXEXEC,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * OSHELL ls -l The OSHELL EXEC generates a (hopefully) unique HFS file name for standard output.

Feedback

Comments or suggestions can be sent to the author.

Last Month's Topic

Big Iron