Example: Running a shell script in batch
You can use BPXBATCH to run a shell script through batch and redirect the output and error messages to z/OS UNIX files or MVS™ data sets. Because the default is PARM='SH', the PARM= is not specified in the following example. The shell script associated with the STDIN ddname is invoked. You can allocate STDIN, STDOUT, and STDERR as z/OS UNIX files, using the PATH operand on the DD statements. You can also allocate STDOUT and STDERR as MVS data sets.
Example: User TURBO runs a shell script in batch, as follows:
- The STDIN ddname defines a shell script to be invoked, /u/turbo/bin/myscript.sh.
- STDOUT defines a file to which to write the standard output, /u/turbo/bin/mystd.out.
- STDERR defines a file to which to write standard error messages, /u/turbo/bin/mystd.err.
//jobname JOB ...
//stepname EXEC PGM=BPXBATCH,REGION=8M
//STDIN DD PATH='/u/turbo/bin/myscript.sh',PATHOPTS=(ORDONLY)
//STDOUT DD PATH='/u/turbo/bin/mystd.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
//STDERR DD PATH='/u/turbo/bin/mystd.err',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
Example: The following JCL is similar to the previous example
and produces equivalent results but uses the PARM= string
to specify the shell script to be run:
//jobname JOB ...
//stepname EXEC PGM=BPXBATCH,REGION=8M,
// PARM='SH /u/turbo/bin/myscript.sh'
//STDOUT DD PATH='/u/turbo/bin/mystd.out',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU
//STDERR DD PATH='/u/turbo/bin/mystd.err',PATHOPTS=(OWRONLY,OCREAT),
// PATHMODE=SIRWXU