Link to home
Start Free TrialLog in
Avatar of iainmacleod
iainmacleodFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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 ftp.ftpsite.com 8021
username
password

prompt

cd INBOUND
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
Thanks
Iain
Avatar of Argenti
Argenti
Flag of France image

Avatar of Kimputer
Kimputer

Actually, I would suggest to cut out the "quote pasv"
Avatar of iainmacleod

ASKER

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..?
User generated image
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 http://www.ncftp.com/).
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.
ASKER CERTIFIED SOLUTION
Avatar of AlexPace
AlexPace
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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"
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.