Thursday, April 28, 2011

scriptable FTP client

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.

From stackoverflow
  • 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
    nowhere@noone.net
    bin
    hash
    prompt
    mget *.*
    quit
    
    Michael Burr : A similar technique should work on Unix as well.
    Arnshea : 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.
    BCS : I can't use anonymous and it's not accepting a password from the file
    Arnshea : In the example nowhere@noone.net 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
    BCS : 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/.
    Arnshea : 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.
    BCS : 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.
  • WinSCP is scriptable

  • wget should work. Try:

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

    BCS : wget had problems with wildcards

0 comments:

Post a Comment