Visit Our UNIX and Linux User Community


Multiple FTP.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple FTP.
# 1  
Old 09-15-2009
Bug 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 Smilie

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.
# 2  
Old 09-15-2009
you can make a file like :
hostname;username;password

Code:
123.123.123.123;abc;xyz
321.321.321.321;cba;zyx

in the script:

Code:
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

# 3  
Old 09-15-2009
If you install lftp, you can ftp files to and from different servers in parallel.
# 4  
Old 09-15-2009
MySQL

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 Smilie
Thank you a lot Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #638
Difficulty: Easy
The original iPhone had 16GB of memory.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ftp multiple files one at a time

Hi, I have a problem while ftp'ing zip files one after the other from linux source directory to a ftp host machine. here is the shell script: #!/bin/ksh dir=data/dir1/dir2 # this dir is linux source directory where zip files located. rmtdir='/home/' echo $dir for i in /$dir/*; do if ;... (7 Replies)
Discussion started by: raj78
7 Replies

2. Windows & DOS: Issues & Discussions

Script to ftp in to multiple ip addresses

Hello Is there an easy way to login to various ip's..one after the other. I need to login to about 30 aix boxes and put a file in each one... Cheers (1 Reply)
Discussion started by: Grueben
1 Replies

3. Shell Programming and Scripting

FTP multiple files from multiple directories

I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure.. ./dir1/1/TRADE_LOG*.gz ./dir2/10/TRADE_LOG*.gz ./dir11/12/TRADE_LOG*.gz ./dir12/13/TRADE_LOG*.gz when I do ftp uisng mput from the "." dir I am getting the below given error mput... (1 Reply)
Discussion started by: prasperl
1 Replies

4. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

5. Shell Programming and Scripting

ftp multiple files from same directory

Hi there Gurus, I have the following ftp script: $ more ftp_dump_arch4.sh #! /usr/bin/ksh # Constant variables HOST='xx.xx.xx.xx' USER='user' PASSWD='password' dir='/export/file' ftp_log='/tmp' ftp -n $HOST > $ftp_log/ftp.log << END user $USER $PASSWD verbose lcd $dir bin (3 Replies)
Discussion started by: lweegp
3 Replies

6. Shell Programming and Scripting

Help in FTP'ing multiple files

Hi, I have written the following FTP script to get the multiple files from remote server to local server. My problem is that 'mget *' is not working in the script. I also tried with 'mget *.txt', 'mget *.*' etc. without any success. It do not copy any file to local server. In the script, Prompt... (10 Replies)
Discussion started by: berlin_germany
10 Replies

7. IP Networking

Automated ftp for Multiple files

I have seen the script posted yesterday for automated ftp Can we do some thing like ftp ing multiple files in one script Example input.txt has all files names to be ftped input.txt ------ a.tar b.ccp c.perl i need to ftp all the files present in input.txt i tried something like... (0 Replies)
Discussion started by: pbsrinivas
0 Replies

8. HP-UX

how to ftp multiple files

Hi, I have to write a ftp script which transfers multiple files from one unix server to another. When I try to transfer single file it goes through successfully. But, When I try to do multiple files none of the files get ftp'd. And also, even the single file goes transferred successfully, I... (4 Replies)
Discussion started by: isingh786
4 Replies

9. Shell Programming and Scripting

Need to send multiple files during ftp

Hi guys... I'm working on #!/bin/sh script in a Solaris 7 box that should send several files over to another machine via FTP. Here's what the script looks like: # This script will send the daily MSP customer counts # to the Crystal Reports server located at 192.168.2.106 cd... (2 Replies)
Discussion started by: cdunavent
2 Replies

10. Shell Programming and Scripting

ftp to multiple servers

Hi folks. I am writing a ksh ftp script. The problem is, I need to transfer the files to several different servers. Is there a way to close a connection and move on to the next in one script or do I need to write a separate script for each one? Thanks, kristy (2 Replies)
Discussion started by: kristy
2 Replies

Featured Tech Videos