Command line FTP "Connection closed by remote host"

I am trying to connect to an FTP site using a .bat file and a .txt file as I am calling those from an application.
When I connect to the FTP site using Explorer I can transfer files with no problem. When I use the command line I get the "Connection closed by remote host" error.
This is my txt file that I use:
@echo off
open 8021


quote pasv
mput ARScan.csv

The command line just sits after the mput for about 30 seconds and the errors.

Any ideas would be greatly received
Who is Participating?
AlexPaceConnect With a Mentor Commented:
You could do it with Robo-FTP like this:
WORKINGDIR "c:\source\folder\"
FTPLOGON "" /port=8021 /user="UserID" /pw="secret"
IFERROR GOTO done   ;; don't upload if can't access INBOUND folder
SENDFILE "ARScan.csv" 

Open in new window

Anyway, if you saved that script as a file named SendScan.s you could launch Robo-FTP and have it run the script with a command like:
  robo-ftp.exe -v -s"SendScan.s"

Open in new window

Actually, I would suggest to cut out the "quote pasv"
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

iainmacleodAuthor Commented:
I have tried without the "quote pasv" with the same result.
Reading the link it looks as though the issue is that Cpmmand Line FTP does not support passive mode, however it looks as though the session enters passive mode?? See Screen Shot. I run the same procedure to another FTP site with no problem so it must be something to do with the passive mode..?
FTP Command screen shot
Yes, my answer was too quick. FTP.exe will actually not support passive mode no matter what commands you throw at it. You have to find an alternative (free from
While you use "quote pasv", the server side sees it, and replies it is entering Passive Mode. This does not mean the client knows anything about it though, that's why nothing happens.
iainmacleodAuthor Commented:
Thanks for the help and suggestion of NCftp but I could not seem to get that started.
AlexPace, the Robo FTP looks the way forward. I have managed to create the script that works when I run it from Robo-FTP itself but I cant get it using the command. The a screen just flashes up and then disappears.
I have tried in a bat file:
"C:\Program Files (x86)\Robo-FTP 3.9\robo-ftp.exe"  -v -s"SendScan.s"
iainmacleodAuthor Commented:
AlexPace, many thanks, I missed adding Robo-FTP to the path.
Thanks very much, spent some money on Robo-FTP but a good solution.
I first got Robo-FTP for one specific project but then other automation needs started turning up and I've ended up using it for many projects over the years.  Scripting it is easier than writing a tiny custom app in Visual Studio plus the IT guys can support it on an ongoing basis because doing something like changing the server address or password does not require editing the source code and recompiling.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.