Hi,
I have created the following FTP script, which transfers daily “.txt” files from remote server in to a timestamped folder on local server. Once all files are FTP'ed, it then deletes files from remote server. When files are FTP'ed, I get a mail messege like, “Files are successfully transfered”, which I have hard-coded in “ftp_succ.msg” file. My problem is that I want to include names of FTP'ed files in this messege. Now, names of files FTP'ed can change everyday, so I can't use a hard-coded pattern messege. Instead I want to be done that by FTP script itself. Can anybody please suggest me, how to do that?
####################################################
# Set local variables
####################################################
export DROPOFF=/temp1
export PICKUP=/temp2
export MSG=/temp1/ftp_messege
export LOG=/temp1/ftp_log
export LOGIN=username
export FTPPASS=password
export DEVICE=remoteserver
####################################################
# FTP'ing files from remoteserver to localserver
####################################################
cd $DROPOFF
mkdir ftp`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`
`ftp -vin <<- END_INPUT > $LOG/ftp_files.log 2>&1
open $DEVICE
user $LOGIN $FTPPASS
cd $PICKUP
mget * .txt
# mget *.* would get all files from current directory.
# By default, prompting would be enabled; if you wish to get all files without being
# prompted, use the "prompt" command to disable/enable prompting.
mdelete * .txt
quit
END_INPUT`
EXIT_STATUS=$?
if [[ $EXIT_STATUS -ne 0 ]]
then
echo "[%s - %s]ERROR: FTP failed with an exit status of %s\n" \
%0 "$(date +'%x %X')" $EXIT_STATUS
mailx -r
xyz@localserver.annonymous.com -s \'"Files FTP failed'"
user@annonymous.com < $MSG/ftp_fail.msg
exit 1
fi
####################################################
# Notifying successful FTP of files
####################################################
mailx -r
xyz@localserver.annonymous.com -s \'"Files FTP complete to localserver successfully'"
user@annonymous.com < $MSG/ftp_succ.msg
exit 0