FTP command hangs at ls or mget (Windows 7 professional)

I have search the web and cannot get a reason why the ftp hangs at ls or mget commands - I have disabled the firewall - opened ports etc but to no avail . .  

This is my bat file :-

FTP -d -s:ftp-ums-script.txt

Open in new window

This is my ums-script.txt :-

open 21
username ****
password ****
literal pasv
cd  25D57C3CE4E343EF9EC3F6EE37644D33
mget *

Open in new window

This is the where it hangs :-

(**** has been replaced with proper credentials)


C:\programs>FTP -d -s:ftp-ums-script.txt
ftp> open 21
Connected to
220 FileZilla Server version 0.9.44 beta Welcome to Unitrade Management Services
 FTP Server
User (
---> USER ****
331 Password required for ****

---> PASS ****
230 Logged on
ftp> literal pasv
---> pasv
227 Entering Passive Mode (41,213,123,46,19,140)
ftp> cd  25D57C3CE4E343EF9EC3F6EE37644D33
---> CWD 25D57C3CE4E343EF9EC3F6EE37644D33
250 CWD successful. "/25D57C3CE4E343EF9EC3F6EE37644D33" is current directory.
ftp> ls
---> PORT 192,168,1,59,203,86
200 Port command successful
---> NLST
150 Opening data channel for directory listing of "/25D57C3CE4E343EF9EC3F6EE3764
BASit BulbuliaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BASit BulbuliaAuthor Commented:
Please note that I can use an external ftp client like filezilla to download the files and it works . . (No hanging) - The issue is i need to use the FTP commands in a batch (.bat) file
Are both FTP clients using passive FTP? if not adjust and try again.

harbor235 ;}
try using hash, to see whether the data is being transfered but just taking a while. without the hash, you have to wait without ack.  The hash will indicate whether data is being slowly transferred.

When you using the ftp client, you should not be issuing the pasv command allowing the FTP client to handle that.

issue dir, are you able to see the directory listing, I think when you issue pasv command, you have to establish the data channel to the port specified in the response.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Passive FTP is normal if you are trying to traverse a firewall,

harbor235 ;}
Although passive FTP is normal when trying to go through a firewall, unless something has chaneged MS's ftp client does not support passive ftp.

So when you do the mget, your client is waiting for the server to initiate the data connection from port 20 to the client.

Because you issued the command "literal pasv"  the server is waiting for the client to initiate the data connect to the port the sever told it to use in the "enter passive mode" response.

So basically both sides are waiting for the other side to do something.

If you need to use passive ftp, then you need to get a different client.
BASit BulbuliaAuthor Commented:
@arnold . . . where exactly do I insert a hash !  Instead of ls I have even tried dir same thing happens it just hangs . . .

I have also tried removing the passive move ; does not help.
Do you have a firewall anywhere between you and the ftp server?

If so, is it setup to allow for active ftp connections?   That is allowing a TCP connection initiated from the server with a source port of 20 to the client with a destination port greater than 1023.
When it hangs, it means it can not establish the data connection.
Hash is a command ( on or off)
Binary or ASCII transfer
Hash (hash on)
Mget filename
Every certain amount of data retrieved will be reflected with a hash
Transfer complete ..

Ithe command line tool is not as versatile as the FTP vile the you mentioned where they have builtin negotiation/determination to use PASV transfer and then initiate the data connection to the server provided info present following the PASV directive.
BASit BulbuliaAuthor Commented:
@arnold - thanks for the explanation - I have put hash on and no # appears.

@giltjr - I disabled the firewall on both sides to test and same thing just hangs.
Based on your comment that when you do dir or ls it hangs, that means you do not have a data channel.

There are alternate FTP command line tools that will include the functionality you need meaning it will determine and make sure the pair of connections are made to facilitate the transfer.
Since you are disabing the firewall on both sides, then do you control both sides?

If so then you may want to run a packet capture to see what each side is seeing.  Based on what you have said so far, I am going to assume that when the data connection is attempted to be made you are going to see the SYN or SYN/ACK leave one side and never get to the other side.
It could also be a mtu issue, see if there is a mtu mismatch, this can cause the symptoms you speak of as well.

harbor235 ;}
mtu would manifest itself when the user used filezilla.

the windows command line ftp client could be/likely the culprit.

looking for an alternative command line ftp client be an option to consider.
Do we have information from which system(s) are being used? Are they originating from the same location?

harbor235 ;}
Just re-read and noticed that Filezilla works.  Filezilla uses passive FTP by default.  So my guess is that the FTP server side is NOT setup to allow/do active FTP and the Windows FTP client does not support passive FTP.

"Please note that I can use an external ftp client like filezilla to download the files and it works . . (No hanging) - The issue is i need to use the FTP commands in a batch (.bat) file "

Like I said, there is no verification that we are talking the same host or location. Regardless if it is or not, ruling it out definitely would be good to know.

harbor235 ;}
It is the same host to the new 2012 server.  The person needs to use the command line client to complete their batch file/file transfer.
Then somebody needs to get active data transfer working or get a Windows based FTP command line client that supports passive data transfers.

There are others I am sure, but WinSCP supports this.  Here is a link on how to convert a Windows FTP script to WinSCP script:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking Protocols

From novice to tech pro — start learning today.