Thanks a lot Srikanthus2002. I did as you mentioned and it's working fine when I try to FTP files in a directory "ftp`date '+%Y%m%d'`" on local server. But, when I try to ftp the same files to one more directory "ftp_verify`date '+%Y%m%d'`" on the local server using 'lcd' command, it do not copy anything there. Actually, to check wether files are FTP'ed correctly on local server, I need to use a verification logic in my script. And to do that I copy files from remote server in 2 different directories on local server and then compare them using 'diff' command in the script. Then after verification I delete the verification directory "ftp_verify`date '+%Y%m%d'`". Can you please explain, why it's not copying files in "ftp_verify`date '+%Y%m%d'`" directory? My scripts is like:
#!/bin/ksh
HOME1=/home/sri
echo " 1"
cd /home
mkdir ftp`date '+%Y%m%d'`
mkdir ftp_verify`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`
ftp -n server_ip << END_INPUT > /tmp/ftp_files.log 2>&1
user username password
cd $HOME1
prompt
mget *.txt # copies files correctly
lcd /tmp/ftp_verify`date '+%Y%m%d'`
mget *.txt # Do not copy anything
bye
END_INPUT
cd /home
diff -w ftp`date '+%Y%m%d'` ftp_verify`date '+%Y%m%d'` > /dev/null
if [ $? -ne 0 ]
then
echo "Error: Files are not successfully FTP'd"
mailx -r
user@vrfai030.private.annonymous.com -s \'"Files FTP failed'"
user@annonymous.com < /tmp/ftp_fail.msg
exit 1
rm -r ftp_verify`date '+%Y%m%d'`
fi
exit 0