Home > other >  Windows FTP Script Fails
Windows FTP Script Fails

Time:09-20

I have a simple ftp script file to upload a file to a server.

Script.txt contains:

open ftp.host.com
user Fred PASSword
send c:\hotsheet.dat
disconnect
quit

The cmd line is

Ftp -s:Script.txt

It starts processing correctly but the login fails. I think it is using all lowercase for my password.

CodePudding user response:

The cmd line is

Ftp -s:Script.txt

Script.txt is

Open ftp.host.com User Fred PASSword Send C:\File.txt Disconnect Quit

It successfully makes the connection, but the login fails. I've confirmed the user and pswd works using filezilla interactively. I wonder if the script method is using all lowercase for PASSword, even though script.txt contains the proper case...

CodePudding user response:

The Windows ftp has two login modes. In the default one (the one you are using), it tries to login automatically once the open command is issued and reads the credentials from the script. So the script would have to look like:

open example.com
username
password
send c:\hotsheet.dat
disconnect
quit

So what is happening with your script is that the user Fred PASSword is used as a username as a whole (and similarly the send c:\hotsheet.dat is used as a password). You can tell that, if you add -d (debug) switch:

---> USER user Fred PASSword
331 Please, specify the password.
---> PASS send c:\hotsheet.dat
530 Login incorrect.
Login failed.

Or you can prevent the automatic login with -n switch:

ftp -s:Script.txt -n

And then explicitly login using the user command, just as your script is doing.

  • Related