How to use Windows Command-line FTP.EXE for Passive Mode Data Transfer

Many people just have this wrong notion that windows command line FTP.exe can not be run in passive mode. It actually can be configured to run. The (undocumented or not well documented in ftp help) QUOTE command is the key here. QUOTE PASV command will set the FTP client to work in passive mode. Below is an example:

ftp>quote pasv

To run a sequence of FTP command from a file you may use Batch command or VBScript. First create your ftp command file (say ftp.txt) in note pad. The content of the file would be as below. Replace the fields with in [] with appropriate values:

open []
quote pasv

Simply write the following in a batch file (say ftp.bat) to execute the ftp.txt content:

c:\windows\system32\ftp.exe -s:c:\ftp.txt

If you want to use VBScript, create a VBScript file (say ftp.vbs) in notepad as well. The content of the script file would be as below:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "c:\windows\system32\ftp.exe -s:c:\ftp.txt", , True
Set objShell = Nothing

Double click on ftp.vbs and voila!





15 thoughts on “How to use Windows Command-line FTP.EXE for Passive Mode Data Transfer

  1. Doesn’t work… Looks like the ftp client is able to send PASV command but doesn’t understand it so now both sides have data connection listener ports.

    quote pasv is useless.

    ftp> open
    Connected to
    220 (vsFTPd 2.0.5)
    User ( anonymous
    331 Please specify the password.
    230 Login successful.
    ftp> quote pasv
    227 Entering Passive Mode (NNN,109,139,134,83,169)
    ftp> ls
    200 PORT command successful. Consider using PASV.
    Aborting any active data connections…

    The last ‘200 PORT command successful’ was hang forever, so I just hit CTRL+C

  2. THANK YOU! i’d been looking for at least 15 minutes before finding your blog and using the ‘quote pasv’ command. It solved my problem!!

  3. I agree with mightybs. I struggled with all the pasv crap. WinSCP com worked like a charm. Takes some time to get used to scripting batch files with it but it works.

  4. This does not set you client to passive mode. It only mimics a passive capable client’s command to the server side. The server will be ready and waiting for your client to open the data channel on the IP and port it specifies, but your client does not understand passive so it won’t do it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s