Hi All Experts,
I have a script which logs to the server via sftp connection with below code :-
and the connection is going smooth.
My requirement is to place file in sftp_server in some path.
and if path doesn't exist or the file is not put successfully I need to raise an exception.
Below is the code which I am using to accomplish my requirement but the error for path doesn't exist is not getting captured.
FTP2NT(){
FILE_INPUT=$1;
USER1=$2;
SERVER=$3;
PATH1=$4;
sftp $USER1@$SERVER <<ENDofFTP
cd $PATH1
put $FILE_INPUT
exit
ENDofFTP
}
FTP2NT $zipfile $user $sftpserver $path
sftp_status=$?
if [ "$sftp_status" = "0" ]
then
echo "Hi \n \t SFTP was successful for $DATE_SEND files." | mailx -s "SFTP success" $mlist
else
echo "sftp was not successful"
echo "Hi \n \t SFTP was not successful. Kindly check the script $0 @ `hostname`." | mailx -s "SFTP process failed" $errorlist
fi
done