Ftp - DOS/Command Prompt Reference
Sn interactive program used to connect to an FTP server and perform file transfers (download/upload).
* This program is not a DOS program but a Windows console program that can be used on Windows 95 and later versions.
* The usage details of ftp.exe will not be described here.
Syntax
ftp[.exe] [-v] [-d] [-i] [-n] [-g] [-s:<filename>] [-a] [-w:<buffer-size>] [-A] [<host>]
* Option characters are case-sensitive. Additionally, unlike other commands, options should follow ‘-’ instead of ‘/’.
- -v
- Suppresses the display of FTP server response messages, except for commands like ‘pwd’ that require response display within ftp.exe.
- Inside ftp.exe, you can switch this behavior using the ‘verbose’ command.
- -d
- Runs ftp.exe in debug mode. In debug mode, all commands sent by ftp.exe to the server are displayed. Please note that the PASS command, which is sent to the server, is displayed without obscuring the password.
- Inside ftp.exe, you can toggle this behavior using the "debug" command.
- -i
- Using the ‘mget’ command and ‘mput’ command inside ftp.exe (used for transferring multiple files), it performs the transfer for all files without prompting for each one. If not specified, you would need to specify whether to transfer each file individually with yes/no/quit (y/n/q) prompts.
- Inside ftp.exe, you can toggle this behavior using the ‘prompt’ command.
- -n
- Prevents prompting for the username when connecting to the server. In this case, you need to use the ‘user’ command inside ftp.exe to specify the username.
- -g
- Disables the usage of wildcards in file names and other contexts.
- Inside ftp.exe, you can toggle this behavior using the ‘glob’ command.
- -s:<filename>
- Specifies a file that contains commands to be executed initially when running ftp.exe. This allows the execution of a kind of script using ftp.exe.
- -a
- When binding for FTP data communication, it utilizes local features. Specifically, the address used by ftp.exe in the PORT command sent to the server is always set to ‘0.0.0.0’.
- -w:<buffer-size>
- Specifies the size of the data communication buffer. If not specified, the default size is 4096.
- -A
- Connects to the server using the anonymous user ‘anonymous’ when establishing a connection. The password (representing an email address) is set to ‘(local computer's)login-username@computer-name’.
- <host>
- Connects to the FTP server ‘<host>’. <host> should be a regular hostname or IP address. ‘ftp://’ is not necessary.
Details
ftp.exe is a program for connecting to FTP from the command line, which comes (almost) standard with Windows. If not using -s, you can interact with the server by manually entering commands, similar to the command prompt. (A list of commands can be obtained by typing ‘help’ inside ftp.exe.)
Samples
Sample 1
ftp ftp.microsoft.com
Connects to the FTP server ‘ftp.microsoft.com’. Upon execution, you will be prompted for a username. Typically, enter ‘anonymous’ for the username (anonymous) and input your email address (or leave it blank) as the password.
Sample 2
ftp -n myserver.net
Connects to ‘myserver.net’ without identifying a username. In practice, once prompted for input, you would need to use the ‘user’ command to identify yourself.
Sample 3 (Batch file)
@echo off echo open ftp.hogehoge.net > ftpscrpt.txt echo user admin mypassword >> ftpscrpt.txt echo lcd C:\LogsFile >> ftpscrpt.txt echo cd /logs >> ftpscrpt.txt echo mget *.log >> ftpscrpt.txt echo bye >> ftpscrpt.txt ftp -v -i -n -s:ftpscrpt.txt del ftpscrpt.txt
Using the echo command, ‘>>’, and etc., this batch file creates a script for ftp.exe and executes ftp.exe with that script. However, please note that in this sample, the password used for FTP connection is directly written, which poses a security concern.