-
Notifications
You must be signed in to change notification settings - Fork 28
Shell script for running JCL jobs on the mainframe via ftp
IBA-mainframe-dev edited this page Nov 16, 2020
·
1 revision
runZosJcl.sh script is intended to execute job from z/OS dataset via ftp
Also, this Shell script template can be used as part of the Jenkins pipeline to automate the launch of JCL jobs.
Link to shell script sources (runZosJcl.sh)
Instructions:
Execution format::
>./runZosJcl.sh [job] [output_file]
-
job
- fully-qualified job name in quotation marks -
output_file
- file where job output log will be saved
Script returns 1 if dataset with JCL was not found or job failed (completed with error or RC>04)
Example:
>./runZosJcl.sh 'USER01.TESTPROG.JCL(TEST)' build_output.txt
runZosJcl.sh
#!/bin/sh
HOST=#Mainframe IP-address here#
USERID=#MF User#
USERPSW=#User password#
echo reading input parameters
INPUTJOB=$1
OUTPUT=$2
echo JCL: $INPUTJOB
echo Output file: $OUTPUT
TMPFILE=tmp.txt
echo run JCL from z/OS
echo "
open ${HOST}
quote USER ${USERID}
quote PASS ${USERPSW}
quote SITE FILE=JES NOJESGETBYDSN
quote SITE JESOWNER=*
quote site jesjobname=*
get '$INPUTJOB' $OUTPUT
bye
" | ftp -nv > $TMPFILE
echo ---------------
cat $TMPFILE
echo ---------------
JOB_ID=$( grep -o "JOB[0-9][0-9]*" $TMPFILE | head -1 )
if [ -z "$JOB_ID" ]
then
echo Error: job was not submitted
exit 1
else
echo Job $JOB_ID was submitted
fi
sleep 5s
echo check rc code
echo "
open ${HOST}
quote USER ${USERID}
quote PASS ${USERPSW}
quote site file=jes
quote site jesjobname=*
ls
bye
" | ftp -nv > $TMPFILE
#echo ---------------
#cat $TMPFILE
#echo ---------------
grep $JOB_ID $TMPFILE
RC_CODE=$(grep $JOB_ID $TMPFILE | grep -o "RC=[0-9]*")
if [ -n "$RC_CODE" ]
then
RC_CODE=$(echo "$RC_CODE" | cut -d "=" -f 2)
fi
if [ -n "$RC_CODE" ] && [ "$RC_CODE" \< "0008" ]
then
echo Job completed successfully
else
echo Error: job failed
res="failed"
fi
rm $TMPFILE
if [ "$res" = "failed" ]
then exit 1
fi
SMP/E
- How do I check if the APAR or the PTF installation?
- JCL job to create SMP/e zones environment and user datasets
- JCL job to customize SMP/e distribution zone environment
- JCL job to customize SMP/e global zone environment
- JCL job to customize SMP/e target zone environment
- JCL job to load PTF information into global zone and SMP/e datasets
- JCL job to install PTF in the SMP/e target libraries
- JCL job to install PTF in the SMP/e distribution libraries
- JCL job for rejecting PTF to clean up the global zone
- JCL job for restoring PTF to clean up the target zone
- Automated build PTF via JCL + REXX template (IN PROGRESS)
- What should I do if RECEIVE ends with RC=12?
Mainframe automation solutions and best practices
- Mainframe DevOps tutorial – How We Bring DevOps and Automation to Mainframe
- Jenkins MF pipeline code example
- Mainframe integration with Jenkins using USS agent
- Jenkins plug in solution for running JCL jobs
- Mainframe troubleshooting platform - APPULSE
- Azure DevOps with MF (IN PROGRESS)
- Zigi
z/OS DevOps scripts
- Shell script for datasets to transfer from UNIX to the mainframe via ftp
- Shell script to run JCL jobs on the mainframe via ftp
- Shell script to transfer changed sources in git to the mainframe via ftp
RACF
REXX scripts
- REXX script to change parameters values in a config file
- REXX script to replace substring in some members of dataset
ISPF
HSM
- HSM dataset level commands
- HSM system commands
- How do I restore datasets anywhere where HSM is working?
Useful tricks
- How to include a library in the current LOGON session
- How to make IBM Java work for TEP file tep.jnlp
- How to migrate one or more data sets to migration volumes
- How to transfer file from Windows to zOS with command line ftp?
- How do I find out which data sets have used the most amount of space?
- How do I convert a hexadecimal date to a readable date on z/OS?
- How do I compare two data sets interactively?
- How do I use 3270 emulators with a larger screen size?
- How do I make some changes in each member of PDS?
- How do I copy data sets to other LPAR?
Batch jobs (JCLs)
- How to automate checking for normal completion of a job (counting the number of lines)?
- How do I create a Data Set or a Data Set member?
- How do I copy a Data Set or a Data Set member?
- How do I fill VSAM with records?
- How do I rename a Data Set in batch?
- How do I delete a Data Set or a Data Set member?
- How do I compress a Partitioned Data Set?
- How do I convert Partitioned Data Set PDS to Partitioned Data Set Extended PDSE and vice versa?
- How do I split a Sequential Data Set or PDS member?
- How do I copy first n records of Sequential Data Set or PDS member?
- How do I work with a Catalog?
- Replacing archaic JCL constructs
- Sample solution to transfer datasets from one system to another using XMIT and ADRDSSU
- JCL job template for evenly dividing the dataset into parts
- How to work with a Catalog?
z/OS System operating
- z/OS network commands
- JES commands
- SDSF commands
- XMIT
- WLM (COMING SOON, STAY TUNED)
- IPL and its maintenance
- Omegamon for Storage
- Omegamon for DB2
z/OS Subsystem operating