• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4926
  • Last Modified:

Windows ftp command "Ftp Connection closed by remote host"

Hello there!

The ftp.exe command from Windows returns the following error "Connection closed by remote host" a while after the "send" comment has been executed.  Any idea why? I want also to mention that the copy action works perfectly with explorer.

Returning data looks like this:

ftp> open xxx.xxx.xxx.xxx
Connected to xxx.xxx.xxx.xxx.
220 Microsoft FTP Service
User (xxx.xxx.xxx.xxx:(none)): ftpuser
331 Password required for ftpuser.
Password:
230 User ftpuser logged in.
ftp> debug
Debugging on .
ftp> literal pasv
---> pasv
227 Entering Passive Mode (xxx,xxx,xxx,xxx,223,18).
ftp> lcd c:\
Local directory now C:\.
ftp> send test.rar test.rar
---> PORT xxx,xxx,xxx,xxx,220,249
Connection closed by remote host.
0
r3helpdesk
Asked:
r3helpdesk
  • 5
  • 3
  • 2
1 Solution
 
jkratzerCommented:
When conducting the transfer in batch, is the file transferring?

You may be able to contact the FTP providor to get the error from there end to see what is going on.

Try using the put command instead of the send command for the file transfer.

To see exactly what is happening when you are sending the file through explorer, run a sniffer application (wireshark) to see what commands explorer is sending.
0
 
r3helpdeskAuthor Commented:
What do you mean with "is the file transferring?

I did but no response until now...

Tried even the put command but is not working.

Yes I can do that but... you can see only the RAW commands... how can I translate a RAW command into a command for ftp.exe? 

0
 
jkratzerCommented:
Look for request lines in the capture.

It would also help if you create a filter for FTP using "tcp port ftp" so you only see the FTP session.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
r3helpdeskAuthor Commented:
I did but the filter was a bit different. I kept the destination address (ftp server) as a constant (ip.dst == xxx.xxx.xxx.xxx) and as requests i cant see too many interesting things... as I said before, the "chat" is made in RAW:

CWD /
LIST
PASS User@
PASS xxxxxxxxx
PASV
PWD
STOR test_file.rar
TYPE A
noop
opts utf8 on
syst

and then lots of ack and syn

what do you think?

0
 
jkratzerCommented:
Looks about correct.

Can you get the logfile from the providor?

I also note that some servers do not like literal pasv.
I tested on one of my FTP servers and got the same response when you use literal pasv.

Set your script to run the commands reflected in the same order you saw from explorer.

Script response file should look something like this...
I added hash so you can watch it transfer.

open xx.xx.xx.xx
user Username
PASS password
PASV
hash
binary
lcd c:\
put  test_file.rar
bye
0
 
AlexPaceCommented:
Are you sure the windows FTP client even supports passive mode?  Clearly the remote server does because it sent a positive response but I'm not so sure about ftp.exe.  I suspect the remote server disconnected after a while because ftp.exe did not initiate the data channel on the port specified in the PASV response.  You might need to use a different FTP client.
0
 
AlexPaceCommented:
Robo-FTP is a scriptable FTP client that supports passive mode.  It was basically designed to automate repetitive file transfers so it should be able to handle your batch processing.  
0
 
r3helpdeskAuthor Commented:
@jkratzer first I want to thank you for your replay but, is not working even using this order of commands. I think the PASV mode is not working correctly...

@AlexPace I agree with you, it must be a problem with ftp.exe initiating the transfer... I will give a shot with winscp, if I remember correctly, winscp is capable of scripting too and is also free :) Thank you

I will update the post after testing this idea.
0
 
r3helpdeskAuthor Commented:
Hello guys!

At the end WinSCP portable edition did the job. I will paste an example of my script maybe I'm not the only one who need this solution.

I created a .bat file which looks like this:

x:\path_to\WinSCP.com /script=script.txt

Open in new window


and here is the content of the script file:

option batch on
option confirm off
open ftp:USERNAME:PASSWORD@XXX.XXX.XXX.XXX
lcd x:\path_to\the_zip_file
put file_name.zip
bye

Open in new window



Thank you all!
0
 
r3helpdeskAuthor Commented:
In the end I found the solution.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now