-
Notifications
You must be signed in to change notification settings - Fork 28
Shell script for transferring changed sources in git to the mainframe via ftp
IBA-mainframe-dev edited this page Aug 9, 2021
·
4 revisions
sendChangedScr.sh was created to send changed sources to z/OS via ftp
Script configuration before execution
- Prepare configuration file
vardefs
by replacing the following values:
HOST=#Mainframe IP-address here#
USERID=#MF User#
USERPSW=#User password#
defaultHLQ='#HLQ of datasets#'
masterBranch=#master branch name#
developBranch=#develop branch name#
- Replace the path to the configuration file in the script:
VAR_PATH="/$PWD/#PATH TO CONFIG#/vardefs"
Sequence of script actions:
- Script retrieves list of modified modules from git
- Sends modules to z/OS
- Puts list of modified modules in [HLQ].DIFF dataset on z/OS
Execution format:
>./sendChangedSrc.sh [HLQ] [restore]
-
HLQ
- datasets qualifiers, required parameter -
restore
- constant value which must be specified to restore changed modules from master branch in case of errors
Script returns 1 if HLQ was not specified, changed modules list is empty or file transfer was unsuccessful.
Execution examples:
>./sendChangedScr.sh USER01.TEST
>./"$PWD"/scripts/zOS/sendChangedScr.sh USER01.TEST restore
sendChangedScr.sh
#!/bin/sh
#get variables values
VAR_PATH="/$PWD/#PATH TO CONFIG#/vardefs"
. "$VAR_PATH"
#get parameters
DSQ=$1
RESTORE=$2
path="$PWD"
TMPFILE=tmp.txt
SENDLIST=difflist.txt
GITDIFF=DIFF
#changesList.txt - saved list of modified modules
CHANGESLIST=changesList.txt
rm $CHANGESLIST
if [ -z "$DSQ" ] || [ "$DSQ" = "restore" ]
then
echo Error: datasets qualifiers are not specified
exit 1
fi
echo datasets qualifiers: $DSQ
#get list of changed modules from git
git diff --name-status origin/${masterBranch}...origin/${developBranch} > $GITDIFF
if [ ! -s "$GITDIFF" ]
then
echo Error: git diff did not find any changes. DIFF list is empty.
exit 1
fi
echo ---------------
cat $GITDIFF
echo ---------------
if [ ! -z "$RESTORE" ] && [ "$RESTORE" = "restore" ]
then
echo restore changed modules from master branch
path="$PWD"/master
else
#add DIFF file in sendlist
echo "$GITDIFF" >> $SENDLIST
fi
#read git diff file and create
# - DIFF file which will be send to z/OS
# - changesList.txt
while read diffline
do
status=$(echo "$diffline" | awk '{print $1}')
dataset=$(echo "$diffline" | awk '{print $2}')
#if ZIGI is used for z/OS Git client:
zigi=$(echo "$diffline" | grep -o "zigi")
rename=$(echo "$status" | grep "R")
if [ ! -z "$rename" ]
then
dataset=$(echo "$diffline" | awk '{print $3}')
fi
if [ "$status" = "D" ] || [ ! -z "$zigi" ]
then
continue
else
echo "$dataset" >> $SENDLIST
echo "$diffline" >> $CHANGESLIST
fi
done < $GITDIFF
echo ---list to send------------
cat $SENDLIST
echo ---------------------------
#send to z/OS modules listed in SENDLIST
while read line
do
if [ ! -f "$path/$line" ]
then
echo Error: $path/$line does not exist
res="error"
continue
else
if echo "$line" | grep -q '/'
then
DIR=$(echo "$line" | cut -d "/" -f 1)
MEMBER=$(echo "$line" | cut -d "/" -f 2)
if echo "$MEMBER" | grep -q '.'
then
MEMBER=$(echo "$MEMBER" | cut -d "." -f 1)
fi
PARAMS='LR=80 BLOCKSIZE=32720 REC=FB TR PRI=10 SEC=100 DIR=20'
echo copy "$line" to z/OS
echo "
open ${HOST}
quote USER ${USERID}
quote PASS ${USERPSW}
quote site $PARAMS
mkdir '$DSQ.$DIR'
cd '$DSQ.$DIR'
lcd $path
put $line $MEMBER
bye
" | ftp -inv > $TMPFILE
echo ---------------
cat $TMPFILE
echo ---------------
else
PARAMS='LR=80 BLOCKSIZE=32720 REC=FB TR PRI=5 SEC=100'
echo copy "$line" dataset to z/OS
echo "
open ${HOST}
quote USER ${USERID}
quote PASS ${USERPSW}
quote site $PARAMS
put $path/$line '$DSQ.$line'
bye
" | ftp -inv > $TMPFILE
echo ---------------
cat $TMPFILE
echo ---------------
fi
fi
ERROR=$(grep -i 'Error' $TMPFILE)
NOTCONN=$(grep -i 'Not connected' $TMPFILE)
if [ -n "$ERROR" ] || [ -n "$NOTCONN" ]
then
echo Error occurred
res="error"
fi
done < $SENDLIST
rm $TMPFILE
rm $SENDLIST
rm $GITDIFF
if [ "$res" = "error" ]
then
echo Sending files completed with errors
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