Here i want to get a mail conformation when ever the file was uploaded to FTP server.Here is my FTP script . Can any one plz help me how to get a mail confirmation weather the file was uploaded or not.
#!bin/sh
HOST='192.168.2.85'
USER='ddd'
PASSWD='dfd'
#FILE='*'
#DT=$(date +%a_%h_%d_%Y)
DT=$(date +%Y-%m-%d)
ftp -n $HOST > .ftpout.txt 2>.ftperr.txt <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
#lcd /home/oracle/test
lcd /u03/APDEXTS/
mkdir TEST
cd TEST
mkdir $DT
cd $DT
prompt
mput *.cec
quit
END_SCRIPT
exit 0
I have added the below code in my script and when the file was uploading we are getting success mail and even when the file was not uploaded also we are getting the same success mail .
Here I changed my ftp server ip and tried to run the script but i am getting success mail only.
I don't think this will work out, ftp command will always end successfully after you enter quit at ftp prompt. How could you check the exit status of ftp command to identify whether the file transimission was successful.
It won't work as far as i have tested. The proper way is to check the ftp logs and check for the error code in the log. You have checck for error codes starting from 300 - 599 for any errors.
Please try this, add the below line before the if condition and just after the END_SCRIPT,