Hi Gurus,
I prepared a script to process some files and then ftp the output file to mainframe directory. Here is the code snippet for the same.
# Perform FTP
echo "put $TGT_DR/$K.$F.$I.$K1.$RUN_TYPE '$K.$F.$I.$K1.$RUN_TYPE'" >> $LogFile
ftp -i -n <<EOF >> $LogFile
open $FTP_HOST
user $FTP_LOGIN $FTP_PASSWORD
cd $K
cd $F
cd $I
cd $K1
cd $RUN_TYPE
ebcdic
put $TGT_DR/$K.$F.$I.$K1.$RUN_TYPE '$K.$F.$I.$K1.$RUN_TYPE'
close
bye
EOF
RC=$?
if [ $RC -eq 0 ] ; then
echo "Successfully FTP'd $K.$F.$I.$K1.$RUN_TYPE to ${FTP_HOST}" >> $LogFile
else
echo "Error! while trying to FTP." >> $LogFile
exit 1
fi
Script works fine and is able to FTP the file. However the execution stops after that even though there is some processing needs to be done after the file transfer. For example, below code needs to be after executed after the FTP. But for some reason, script exits from the operation and log file shows the entries only till FTP initiation.
printf "FTP'd $K.$F.$I.$K1.$RUN_TYPE to Host:$FTP_HOST" | mailx -send -s "Process has completed on $DOMAIN and the output file has been FTP'd" `echo ${Alertlist_All}`
rm $SRC_DR/sample.txt $TGT_DR/$K.$F.$I.$K1.$RUN_TYPE
echo "`date` : End of xxx.ksh script execution" >> $LogFile
echo "=============================================================================================================================" >> $LogFile
Thanks,