FTP file to different hosts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP file to different hosts
# 1  
Old 08-06-2008
FTP file to different hosts

Guys hw ya all doing.by the way wrote a script which is below.

f()
{

for host in hostname1 hostname2; do
{
#host=hostname1
user = 'rocky'
pass = 'rocky'
#ftp to particular server

ftp -v $host
quote USER $user
quote PASS $pass
bin
cd /bin/rocky
mkdir rock
cd /bin/rocky/rock/
mput file1

bye
}
done
}
f

I need to ftp to those two servers(hostname1 &hostname2) and put the file (file1) in tht particular path.while iam using this script the script is again asking me for login instead of reading the username and password provided.cn some one help me with this.

Thanks fellas
CK
# 2  
Old 08-06-2008
Code:
f()
{
  for host in hostname1 hostname2; do

    user=rocky
    pass=rocky

    #ftp to particular server

    ftp -v $host <<-EOF
	USER $user
	PASS $pass
	bin
	cd /bin/rocky
	mkdir rock
	cd /bin/rocky/rock/
	mput file1
	bye
EOF

  done
}

# 3  
Old 08-06-2008
I beleive you would use:

ftp $user:$pass@$hostname

do a man ftp
# 4  
Old 08-06-2008
When I ran the modified script I got the output like this.

OUTPUT:


Connected to hostmachine1.
220- _________________________________________________________________

220 (vsFTPd 1.2.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (hostmachine1:rocky): 331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
?Invalid command
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
mput file1? 530 Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
530 Please login with USER and PASS.
ftp: bind: Address already in use
221 Goodbye.
Connected to hostmachine2.
220- _________________________________________________________________
220-
220 (vsFTPd 1.2.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (hostmachine2:rocky): 331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
?Invalid command
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
mput file1? 530 Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
530 Please login with USER and PASS.
ftp: bind: Address already in use
221 Goodbye.
# 5  
Old 08-06-2008
It is better to put the name and password in your .netrc file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. Shell Programming and Scripting

How to synchronise a file to 2 different hosts?

Hello, We ve got 2 sites (Site1, Site2), joined thanks vpn. We had 2 differents files with a list of all host in each sites. Server1 has list1.ini, and Server2 has list2.ini everyone from Site1 update list1.ini by ssh or script to Server1 everyone from Site2 update list2.ini by ssh or... (1 Reply)
Discussion started by: cterra
1 Replies

3. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

4. UNIX for Dummies Questions & Answers

Hosts file

What are the xid and cid numbers in a host file used for on solaris? If possible can I get a detailed link on the configuration of hosts file explaining xid and cid. :o (1 Reply)
Discussion started by: usm4n
1 Replies

5. Shell Programming and Scripting

rsh to many hosts the ftp output to single host

Hi guys. i need some help, i need to create a script in tcsh that rsh into all my hosts that we have at our business, then cd to a directory (cd /apps/users) then grab a file from the users folder and ftp it back to my windows machine. can someone please help? Kind regards. Brian Behrens (2 Replies)
Discussion started by: brian112
2 Replies

6. UNIX for Advanced & Expert Users

ftp into remote hosts

Hi all, Have used ftp to transfer files from remote host to localhost. I was wondering how can I ftp into remote hosts. for example from a unix box, connect to an external server and then ftp that file into mainframe ? I would like to avoid pulling it to unix box and then ftping to mainframe.... (1 Reply)
Discussion started by: kodermanna
1 Replies

7. AIX

range in hosts file

We have a server that need to have 50 or so entries added to the /etc/hosts file. All the entries will be on the same subnet so i wanted to know if i can add the range to the /etc/hosts file and if so how. (4 Replies)
Discussion started by: daveisme
4 Replies

8. UNIX for Dummies Questions & Answers

HOSTS File

Hi All, I am to the UNIX world and want to know if I can specify a range of IP addresses instead of having to include one by one on the HOSTS file. Can I just say 127.20.1.1 to 127.20.1.156 ? Or the only way is to put one by one along with the machine name next to the IP ? THANKS (4 Replies)
Discussion started by: cymerman
4 Replies

9. UNIX for Dummies Questions & Answers

hosts.allow & hosts.deny

Hi! Im trying to use host.allow & host.deny to resrtic access to my sun machine, but it doesnt seem to work... I want to allow full access from certain IPīs (ssh,http,ftp,etc...) but deny all kind of conections from outsideworld, the way that im doing that is: hosts.allow ALL:127.0.0.1... (2 Replies)
Discussion started by: Sorrento
2 Replies

10. IP Networking

dns and hosts file

ok i have a question now when i add machines on network that are running unix do i add them in the /etc/hosts file also include them in dns (4 Replies)
Discussion started by: rmuhammad
4 Replies
Login or Register to Ask a Question