FTP script needs blank line

Ones and Zeroes asked:

I am trying to determine the reason for some FTP servers requiring a blank line in the script as follows:

open server.com
username

ftp_commands
bye

Refer to blank line required after username credentials.

Example from: FTP from batch file

another reference to the same:
http://newsgroups.derkeiler.com/Archive/Comp/comp.sys.ibm.as400.misc/2008-05/msg00227.html

Also discussed here:

archive.midrange.com/midrange-l/200601/msg00048.html “The behavior
I’m observing is the same as if I didn’t specify the password to
login.” with an answer referring to our same fix…
archive.midrange.com/midrange-l/200601/msg00053.html and
archive.midrange.com/midrange-l/200601/msg00065.html

Note: It is my experience that FTP questions attract uncouth responses. Admittedly FTP is outdated, but many clients still have legacy systems, which they cannot upgrade or replace. The reason thereof should not be discussed here. The intention of this question is to invite a positive response. Please do not respond if you disagree with the above. If you have never encountered this same issue, please do not respond.

I suspect this may be limited to FTP scripts executed from Windows machines, but have been told that this happens often and with many different servers.

My specific interest is to understand what may cause this as I have a real world example of a production system suddenly requiring this as a workaround fix, after running for many years without issue. The server belongs to a third party who claims no change on their end. Server details unknown and cannot be determined.

Any help or encouragement from someone who has come across the same, would be appreciated.

ps. Sorry for the many words and references to painful responses, but I have asked similar questions on serverfault and elsewhere and unfortunately got back kneejerk responses to FTP and respondents debating the validity of the question. I would truly not ask, or re-post this question online if I had a better understanding of the issue. I know of people who have seen this issue, but don’t know what causes it.

I am wary that this question would again turn into another irrelevant discussion.
Please, I ask very nicely: Please do not respond if you have not encountered a similar issue.

FURTHER EDIT: Please do not suggest changing the product. The problem is not the blank line requirement. We know this fixes the issue. The problem is not being able to explain the reason for the blank line in the first place. Slight difference, but a critical point to note wrt the answering of this question.

My answer:


This comes out of the dim recesses of my memory, as I haven’t had to script command line FTP in this way since, oh, the 90’s…

In an FTP protocol session, after sending the username to the FTP server, the server may then ask for a password, even if the username indicates that anonymous FTP should be used (i.e. the username sent is ftp or anonymous). In this case, the server requests the password but ignores it. So in a script that drives the command line FTP client, a blank line would be used to send an empty password. If the server doesn’t ask for a password, the blank line does nothing and is harmless.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.