ad Point 3) reading from files defined by DD names.
Here is an example for running a python script from a batch job.
//MMPY JOB MM,CLASS=K,MSGCLASS=X
//*
//* Batch Unix Program Spawn Local (BPXBATSL)
//*
//* Note: - Environment Variables are not expanded in PARM
//* - STDENV needed to set env (profile not used)
//* - STDPARM overcomes line limitation, parameters
//* may be split over several lines
//*
//BPX EXEC PGM=BPXBATSL,
// PARM='PGM /u/mm/py27/bin/python /u/mm/apy/ddreader.py'
//*
//DDIN DD DISP=SHR,DSN=MM.JCL(PY2PUB)
//*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *
PY27=/u/mm/py27
LIBPATH=/u/mm/py27/lib:/lib:/usr/lib:.
PYTHONHOME=/u/mm/py27
PYTHONPATH=/u/mm/py27/lib/python2.7
_BPXK_AUTOCVT="ON"
_BPX_SHAREAS=MUST
_BPX_BATCH_SPAWN=YES
//
Important is to use the BPXBATSL that does the spawn of the python program instead of BPXBATCH which does an exec that creates a new job step for python thus loosing the DD names.
See also Unix System Services Command Reference
Appendix D. Running shell scripts or executable files under
MVS environments
The DDIN DD name is being used in the python script ddreader.py
from oe2a import tt1047_819
f2=open('//DD:DDIN','r')
print '--- Reading from //DD:DDIN'
for line in f2.read().translate(tt1047_819).split('\n'):
print line
print '--- ddreader.py terminated'
Obviously, the file tagging does not work for z/OS files, so the python program needs to handle text conversion itself. Due to the swapped nl,lf byte codes the standard EBCDIC encodings e.g. cp037 provided with Python do not work for line breaks.
Would be nice if the Rocket Python would provide these encodings so the kludgy code with the translate table could be replaced by a readline from a file that was opened with encoding.