I have the following UNIX script which copies a file from a UNIX server in Canada to a UNIX server in the UK.
LOG=/data/proj/sftp/canada.log
DAT=`date "+%d/%m/%y %H:%M"`
HOMEDIR=/data/proj/sftp
TGTFILE=P_DATA.csv
cd $HOMEDIR
echo "\nStarting retrieval of Canadian Data at $DAT" >> $LOG
# move old copy of file
if [ -f $TGTFILE ]
then
mv $TGTFILE $TGTFILE.prev
echo "Existing $TGTFILE renamed with .prev suffix" >> $LOG
fi
# get new file using sftp
echo "Using sftp to connect to
ftppora1@sxmq1014.pftg.ca" >> $LOG
sftp -b $HOMEDIR/ftpcmd -oPort=32
ftppora1@sxmq1014.pftg.ca 2>>$LOG 1>>$LOG
# check file retrived successfully
if [ -f $TGTFILE ]
then
echo "$TGTFILE retrieved successfully" >> $LOG
else
echo "*** Error retriving data ***" >> $LOG
exit 1
fi
exit 0
At present, I can run this script by logging onto the server as user xxxxx with password zzzzzz.
I want to automate this process - and wish to kick off the above script from JCL on the mainframe. I've been advised that an OPC job using TWS can be used, as this enables a remote ID and password to be specified on the appropriate job step. Anyone have any example JCL to do this?