Hi
Please find below given script which is working on one of my server
# !/bin/sh
ftp -n
1.1.1.1 <<EOF
user $USER $PASSWD
lcd /opt/remote
binary
prompt
ls -l > list.txt
mget list.txt
quit
EOF
exit
# END OF SCRIPT
now put of conditions by reading list.txt on your location m/c. And download if you find required files.
More options explaination are as below.
1. What is the "-n" paramter do for the ftp command
man ftp
-n Do not attempt "auto-login" upon initial connec-
tion. If auto-login is not disabled, ftp checks
the .netrc file in the user's home directory for
an entry describing an account on the remote
machine. If no entry exists, ftp will prompt for
the login name of the account on the remote
machine (the default is the login name on the
local machine), and, if necessary, prompts for a
password and an account with which to login.
2. Why do you need "<<EOF" at the end of the ftp command.
To tell the FTP program when to "exit"
3. What does the "binary" command do?
set ftp transfer in "binary" mode
Thanks
Kaushal