I was running a Python script via BPXBATCH, with no problem. Then I extended it, and it was unable to find a load module. In getting this to work, I found out a lot about using BPXBATCH, and how things do not work as documented.
Getting started
You can run a shell program, or a “module” (program).
Use STDPARM
This can be used instead of specifying PARM=…. It avoids the 100 character restriction of PARM=…
You can use EXPORT SYMLIST, and SYMBOLS=EXECSYS for JCL variables to be passed into the DD * data.
// EXPORT SYMLIST=* // SET PY='/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3' // SET PR='/u/tmp/zos' //STEP1 EXEC PGM=BPXBATSL, //STDPARM DD *,SYMBOLS=EXECSYS pgm &PY &PR/my.py' /* //STDOUT DD SYSOUT=* //STDERR DD SYSOUT=* //SYSDUMP DD SYSOUT=* //CEEDUMP DD SYSOUT=* //STDIN DD DUMMY
This will execute program /usr/lpp/IBM/cyp/v3r8/pyz/bin/python3 and pass /u/tmp/zos/my.py
Run a program
You can use JCL like
// SET PY='/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3' // SET PR='/u/tmp/zos' //STEP1 EXEC PGM=BPXBATSL,PARM='pgm &PY &PR/my.py' //STDOUT DD SYSOUT=* //STDERR DD SYSOUT=* //SYSDUMP DD SYSOUT=* //CEEDUMP DD SYSOUT=* //STDIN DD DUMMY
This will execute program /usr/lpp/IBM/cyp/v3r8/pyz/bin/python3 and pass /u/tmp/zos/my.py
Run a shell
//STEP1 EXEC PGM=BPXBATSL,REGION=0M,TIME=NOLIMIT,MEMLIMIT=NOLIMIT, // PARM='SH /u/tmp/zos/cc.sh' //STDENV DD * PATH=/u/abc/ xyz=123 //STDOUT DD SYSOUT=* //STDOUT2 DD SYSOUT=* //STDERR DD SYSOUT=* //SYSDUMP DD SYSOUT=* //* SABEND DD SYSOUT=* //CEEDUMP DD SYSOUT=* //STDIN DD DUMMY
This runs the shell script /u/tmp/zos/cc.sh.
Because this is a shell script, there are some profiles that may run before the script executes.
The documentation says in Customizing the shell environment variables
The places to set environment variables, in the order that the system sets them, are:
1. The RACF® user profile.
2.The /etc/profile file, which is a system-wide file that sets environment variables for all z/OS shell users. This file is only run for login shells.
3.The $HOME/.profile file, which sets environment variables for individual users. This file is only run for login shells.
4.The file named in the ENV environment variable. This file is run for both login shells and subshells.
5.A shell command or shell script.Later settings take precedence. For example, the values set in $HOME/.profile override those in /etc/profile.
Colin’s notes
- I cant find how to set any environment variables in the RACF profile.
- The /etc/profile is only run if a shell(sh) command is issued
- The $HOME/.profile. This needs a home entry in the RACF userid OMVS segment ( Use the TSO RACF command LU userid OMVS to display the OMVS information)
- I specified a file in the ENV environment variable – this was not used. If the file did not exist it did not produce an error message. When I had //STDENV DD *… in my JCL the statements were used
//STDENV
When I used
//STDPARM DD * sh export //STDENV DD * PATH=/u/abc/ xyz=1234 yy="ABCD" xx=$xyz /*
The export command listed all of the environment variables. These included
PATH=”/bin:/usr/sbin:/usr/lpp/jav….
xx=”\$xyz”
xyz=”1234″
yy=”\”ABCD\””
- My PATH statement was not used. It was overwritten by /etc/profile (or $HOME/.profile)
- The special characters $ and ” have been escaped.
- It is not doing shell processing, for example in a shell xx=$xyz, says assign to xxx the value of zyz. All that happens is xx is assigned the literal value $xyz
So overall – it didn’t work as I expected it to, and I need to do some redesign.
Using BPXBATSL
When I copied some JCL which used BPXBATSL I got
BPXM018I BPXBATCH FAILED BECAUSE SPAWN (BPX1SPN) OF /BIN/LOGIN FAILED WITH RETURN CODE 0000009D REASON CODE
0B1B0473
BPXBATSL is an alias of BPXBATCH. I do not think it supports the SH command.