Posted by: dcsaha | November 14, 2010

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>open
userid:
password:
ftp>quote pasv
ftp>binary
ftp>put
ftp>quit

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 [siteaddress.com]
[userid]
[password]
quote pasv
binary
put
quit

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!

 

 

 

About these ads

Responses

  1. is not working

    • There were some error in batch file commands, corrected now.

  2. The quote pasv command will only put the server in passive mode.

    to fix this you need an ftp client like: http://www.passive-ftp.com

    which will run in passive mode.

    • Agreed, only the server is in PASV mode, not the client.

      As already mentioned, there is ‘Passive-ftp.’ (for ~$60) and there is NCFTP (http://www.ncftp.com) which works a little different but free.

  3. 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.

    C:\development\projects\dm3\trunk\dbobjects>ftp
    ftp> open http://ftp.company.com
    Connected to http://ftp.company.com.
    220 (vsFTPd 2.0.5)
    User (ftp.comapny.com:(none)): anonymous
    331 Please specify the password.
    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

  4. You could always use this: http://winscp.net/

    I had forgotten this was an issue, and that I solved it using WinSCP instead.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

Join 487 other followers

%d bloggers like this: