Multiple FTP.

Hi,

I'm trying to create a loop to ftp files from different servers.
The script i'm using to ftp a file from one server is as follows, and i'm scratching my head how to make this a loop that will do ftp from different servers.

FILE_NAME="ULOG.`date +"%m%d%y"`"
HOST='MY-IP'
USER='USER'
PASSWD='PASSWORD'
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
cd /opt/tuxedo/logs/d2d_2
get $FILE_NAME
EOF
mv ULOG.`date +"%m%d%y"` ULOG.T$i.`date +"%m%d%y"`
done

[Modified the part of script which i actually got from our forum.]

Here i'm renaming the transferred file so as to differentiate it from the other log file.

My friend gave me a idea like create a file which contains all the other server's credentials and make the script to read that file and so that it makes ftp while the loop is running, but i could not able to catch up how to implement that, even he too :smiley:

So if any of you guys have any idea on how to implement this loop would be a great help for me.

Thank you in advance.

With Best Regards,
Bhargav Kesavan.

you can make a file like :
hostname;username;password

123.123.123.123;abc;xyz
321.321.321.321;cba;zyx

in the script:

while read LINE
do
 
host=$(echo "$LINE" | awk -F";" '{print $1}')
user=$(echo "$LINE" | awk -F";" '{print $2}')
pass=$(echo "$LINE" | awk -F";" '{print $3}')
 
echo "host is $host"
echo "user is $user"
echo "pass is $pass"
## do whatever you want on each host 

done < myfile

If you install lftp, you can ftp files to and from different servers in parallel.

thank you anchal_khare; i'll try this tomorrow and let you know how it worked.

And fpmurphy, thank you for your reply; i'll install it and give a try to that too.[COLOR="\#738fbf"]

---------- Post updated at 10:45 AM ---------- Previous update was at 09:55 AM ----------

Hi anchal_khare, this works absolutely :slight_smile:
Thank you a lot :slight_smile: