Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use a batch file to download a package off my FTP server.

echo username >ftp.txt
echo >>ftp.txt
echo cd directory  >>ftp.txt
echo get filename >>ftp.txt

ftp -s:ftp.txt

The server is set to allow anonymous logins on username but when I run the script I get an error: 331 Password required for username

If there is any other useful information let me know.


share|improve this question
What happens when you connect in interactive mode ? – Luc M Apr 5 '10 at 18:47

Try "anonymous" as the login and an email address as the password. This is a very old standard for anonymous FTP.

share|improve this answer
Only a specific username is allowed anonymous access and it does not require a password – Buzkie Apr 5 '10 at 19:06
Then you should be able to provide a script by recreating exactly what is typed when you login via an interactive session. – Chris Nava Apr 5 '10 at 20:45

Did you try to begin your ftp.txt with


You could use

ftp -s:ftp.txt


So I would try, in your ftp.txt



Note the blank line after the username.

share|improve this answer
Same result as before. – Buzkie Apr 5 '10 at 18:37

What's the FTP server? Some say "anonymous" log in but still require something to be entered as a password (usually it's looking for an e-mail address) before it will accept the log in. What's the behavior when you connect to the account using a regular FTP client with a blank password?

share|improve this answer
When I connect manually I do "FTP" it prompts for user: "username" it says I'm allowed to do anonymous login and asks for a password (suggesting email): "I hit enter" and I'm in – Buzkie Apr 5 '10 at 19:00
up vote 0 down vote accepted

The trailing space where i was inserting into the textfile was screwing up the login

I removed the spaces and it's letting me in.

Thanks for the suggestions


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.