The BPXBATCH utility

BPXBATCH is a utility that you can use to run shell commands or executable files through the batch facility. You can invoke BPXBATCH from a batch job or from the TSO/E environment (as a command, through a CALL command, or from a CLIST or REXX EXEC).

For detailed information about BPXBATCH, see The BPXBATCH utility in z/OS UNIX System Services Command Reference.

BPXBATCH has logic in it to detect when it is running from a batch job. By default, BPXBATCH sets up the stdin, stdout, and stderr standard streams (files) and then calls the exec callable service to run the requested program. The exec service ends the current job step and creates a new job step to run the target program. Therefore, the target program does not run in the same job step as the BPXBATCH program; it runs in the new job step created by the exec service. In order for BPXBATCH to use the exec service to run the target program, all of the following must be true:
  • BPXBATCH is the only program running on the job step task level.
  • The BPX_BATCH_SPAWN=YES environment variable is not specified.
  • Start of changeWhen fork or exec is used to run a target program or sh, the STDOUT and STDERR ddnames are not allocated as MVS™ data sets. STDOUT and STDERR can be defined to MVS files when spawn or local spawn is used.End of change

If any of the these conditions is not true, then the target program runs either in the same job step as the BPXBATCH program or in a WLM initiator in the OMVS subsys category. The determination of where to run the target program depends on the environment variable settings specified in the STDENV file and on the attributes of the target program.

Restriction: File and data set allocation considerations vary when a BPXBATCH or BPXBATSL request is processed in the same address space via local spawn or forked to another address space. Allocations for any files and data sets other than stdin, stdout, stderr, or stdenv and STEPLIB are not available to a program when BPXBATCH uses fork() or exec (STEPLIB EXCLUDED) to run a program in another address space. Data sets that are allocated in JCL, TSO, or an application may conflict with data sets used by BPXBATCH.