tags:

views:

260

answers:

3

I need to have a script download all file in a given directory. I only have ftp access.

A quick test shows that I can't talk my ftp client into logging in from the command line. Even after trying Arnshea's answer it refuses to read the password from the file or stdin.

Even after logging in I can't download wild cards. (fixed with mget, thanks Arnshea)

Trying wget also fails.

I'd be fine with windows or Linux as long as it's simple.

+6  A: 

if you're on windows you can pass it a text file with the commands to execute...

e.g.,

ftp -s:ftptest.txt ftp.download.com

where ftptest.txt contains

anonymous
[email protected]
bin
hash
prompt
mget *.*
quit
Arnshea
A similar technique should work on Unix as well.
Michael Burr
Yep, it's hellaciously insecure but heh, security wasn't part of the OP :) Also, -A can be used in place of the first 2 lines.
Arnshea
I can't use anonymous and it's not accepting a password from the file
BCS
In the example [email protected] was the password. You'll need to change that to whatever the password is. Same goes for anonymous (change it to your user name). Don't use -A if you're not using anonymous
Arnshea
That's what I was trying. As I said FTP won't take the password from the file. When I tried using stdin redirection, it gets to the password prompt and waits for input from the /keyboard/.
BCS
Not sure what's happening on your system. You sure the password is correct? Also, make sure the text file is plain text (e.g., use notepad not wordpad). Works fine for regular and anonymous users on my XP system.
Arnshea
try it for some non anon login. IIRC the same thing happens on Linux, so whoever wrote ftp thought getting a pw from a file/pipe was a "bad thing" (social engineering and all) and made it not work.
BCS
+1  A: 

WinSCP is scriptable

Mark Biek
+1  A: 

wget should work. Try:

wget ftp://domain.com/full/path --ftp-user=username --ftp-password=password

Yuval A
wget had problems with wildcards
BCS