The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help: Script to edit the hosts, network and eth0 file Shaikjaveed Shell Programming and Scripting 1 07-22-2008 04:34 AM
ping hosts from config file za_7565 Shell Programming and Scripting 1 01-29-2008 05:42 PM
Copy a file to multiple hosts sumsriva UNIX for Advanced & Expert Users 5 09-18-2007 03:42 AM
HOSTS File cymerman UNIX for Dummies Questions & Answers 4 01-19-2007 12:26 PM
dns and hosts file rmuhammad IP Networking 4 11-12-2003 02:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-06-2008
coolkid coolkid is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
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 (permalink)  
Old 08-06-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
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 (permalink)  
Old 08-06-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
I beleive you would use:

ftp $user:$pass@$hostname

do a man ftp
  #4 (permalink)  
Old 08-06-2008
coolkid coolkid is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
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 (permalink)  
Old 08-06-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
It is better to put the name and password in your .netrc file.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0