Setting this up was relatively easy. I used JCL
// PROC P=’cons’
// SET PY=’/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3′
// SET PR=’/u/tmp/console’
//*
//STEP1 EXEC PGM=BPXBATSL,REGION=0M,TIME=NOLIMIT,MEMLIMIT=NOLIMIT,
// PARM=’PGM &PY &PR/&P..py’
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//STDIN DD DUMMY
As part of this work, I also developed zconsole which allows a program to get the parameters on the start command, any modify command (and the data), and the stop command.
I tried using print to //SYSOUT2, but was unsuccessful. I could write to a Unix file, but not to a “DD:…” statement.
Following on from a suggestion from Peter Sylvester I used AOPBATCH, and got that working as well.
// SET PY=’/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3′
//*
//AOP EXEC PGM=AOPBATCH,PARM=’/&PY. //DD:STDIN P1 P2′
//STDIN DD PATH=’/u/tmp/zos/z.py’
//STDENV DD *
PATH=/usr/lpp/IBM/cyp/v3r8/pyz/bin:/u/tmp/zos
LIBPATH=/u/tmp/zos
PYTHONPATH=/u/tmp/zos
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDOUT DD SYSOUT=*
//…
This read from the Unix file in STDIN.
The parameters passed to the Python script are P1 P2
DD statements
If you use AOPBATCH you have access to DD statements. I had an external function which opens datasets, and I was able to use
//R EXEC PGM=AOPBATCH,REGION=0M,TIME=NOLIMIT,MEMLIMIT=NOLIMIT,
// PARM=’//usr/lpp/IBM/cyp/v3r8/pyz/bin/python3 /u/tmp/zos/z.py “DD:COLIN” r ‘ //STDOUT DD SYSOUT=*
//COLIN DD DISP=SHR,DSN=COLIN.VB
With this I was able to successfully use the C function, “fopen(“DD:COLIN”,”r”); .
When I used BPXBATCH I got
fopen() failed: EDC5129I No such file or directory. (errno2=0x05620062)
One thought on “Running Python as a started task (or from JCL) on z/OS”