Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! How do I start an ftp script in unix/linux?

Status
Not open for further replies.

ZK

MIS
Oct 2, 2000
27
GB
Hi there,

Any help is much appreciated.

I wrote an ftp script and started it using the command:-

ftp -s:<scriptname>.ftp

This worked fine under DOS, but doesn't work under unix. I looked under 'man ftp' and the '-s' command is not there. So how do I start an ftp script under script?

Thanks
ZK [sig][/sig]
 
The standard ftp client doesn't support scripting directly. However, check your Linux CD for &quot;lftp&quot;. This is an FTP client that allows scripting. For example, the following FTP script logs in to a server as &quot;anonymous&quot; sending email address as password, then goes to a directory and gets a listing.
[tt]
open ftp.mirror.ac.uk
user anonymous my.email@somewhere.com
cd /sites
ls
[/tt]
You would call it using:
[tt]
lftp -f scriptname.ftp
[/tt]
Hope this helps
[sig]<p> Andy Bold<br><a href=mailto: > </a><br><a href= > </a><br>"I've probably made most of the mistakes already, so hopefully you won't have to..." Me, most days.[/sig]
 
You could of course include FTP in a script: -

#!/usr/bin/ksh

ftp ip.address << EOF
params
params
params
EOF


[sig]<p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>Top man[/sig]
 
Or try using the [tt]$HOME/.netrc[/tt] file in your account... try searching the docs for it. [sig][/sig]
 
Actually, the command to invoque ftp and interpret scriptname is:
ftp -vin<scriptname

scriptname would read:
open server
user username password
binary (or ommit for default "ASCII")
put sourcename destinationname
bye

 
My variation:
Code:
ftp -i -n -v <<-EOF
   open HOST
   user USER PASSWORD
   bin
   cd /DIR
   prompt
   mput YADDA* 
   bye
EOF
 
Lol five years! That's a long time to wait at the command prompt for a command hehe

Kordaff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top