• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
FTP\windows\system32\ftp.exe

File Transfer Protocol; transfer files between two computers, typically across the Internet.

To Open

Command Prompt ftp

Usage

ftp url
ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-w:size] [host]

Description

FTP is used to transfer files to and from a remote computer, typically on the Internet. Like many Internet applications, FTP is a client application that requires a corresponding FTP server to work. When you start FTP, you are connecting to a remote host and then issuing commands to instruct the host to send or receive files, display directory listings, and so on.

Although each FTP session requires a username and password, there's a very common workaround that allows anonymous connections. Typically, one enters anonymous as the username and an email address (or, frankly, any bogus text) as the password to log in (assuming anonymous access is allowed on the server at all).

Once you've logged in, commands are issued by typing in the prompt; the complete list of FTP commands is documented later in this section. The exception is when FTP is run in noninteractive mode using the url option.

Command-line parameters for FTP are as follows:


url

A web-style address ( URL) to a specific file located on an anonymous FTP server, which looks something like this:

ftp://server.com/path/file

If you specify a complete URL, FTP will download the file and then quit automatically, rather than going into interactive mode.


host

Specify the hostname or IP address of the remotehost (server) to which to connect. If omitted, it can be entered once FTP has started by using the open command. Example:

ftp ftp.microsoft.com

Note the common ftp. prefix, while not mandatory with FTP, is merely a hostname that signifies a specific machine, often solely devoted to serving FTP requests.


-v

Suppress the display of remote server responses to commands — useful if you're running FTP from a script.


-n

Suppress auto-login upon initial connection. To connect, you'll need to use the user command once FTP is running.


-i

Turn off interactive prompting during multiple file transfers when using the mget and mput FTP commands.


-d

Enable debugging, displaying all FTP commands passed between the client and server (for troubleshooting purposes).


-g

Disable filename globbing, which permits the use of wildcard characters in local file- and pathnames. (See the FTP glob command.)


-s: filename

Specify an FTP script, a plain text file containing sequential FTP commands, one per line. The commands are issued as though they were typed at the keyboard.


-a

Use any local interface when establishing a connection.


-A

Login as anonymous (note capital A). This is the same as logging in normally and manually typing in anonymous as the username and an email address as the password.


-w: size

Override the default transfer buffer size of 4096. Change only if you encounter performance problems.

Note that you can start FTP without any command-line parameters to enter interactive mode, but you won't be able to use most of the commands until you log in with the open command (see below).

FTP commands

The following list shows the commands available once FTP is running. Most require that a connection has been established and not all will work with every FTP server. The most important commands to know are put, get, mput, mget, cd, lcd, dir, and bye. If you are transferring binary files across platforms (from a Unix host to a Windows-based client, for example), be sure to use the binary command first, or the files may be corrupted in transit.


! [ command]

Run the specified command (e.g., cd) on the local computer, as though you temporarily jumped out of FTP, ran a command, and then jumped back in — all without disconnecting. Naturally, you could just open a second command prompt window, but some contextual commands, such as cd (see Appendix C) require the use of the ! command to be effective. Type ! by itself to start a mini-DOS session in which you can type multiple commands; type EXIT to return to the active FTP session.


? [ command]

Same as help.


append

Append a local file to a file on the remote computer.


ascii

Set the file transfer type to ASCII (plain text), the default (except in noninteractive mode). ASCII mode is the default and is useful if you're transferring plain text files between Unix and Windows systems, as minor translation must be performed on these types of files. Note that this translation can corrupt binary files, so you should use the binary command if you're not transferring ASCII files.


bell

Turn on or off the beep after each file transfer command is completed. By default, the bell is off.


binary

Set the file transfer type to binary, a crucial step for transferring nontext files (such as .zip, .gif, and .doc) between Unix and Windows-based machines. Although it's not necessary if the server is also a Windows system, it's a good idea to get into the habit of typing binary (or simply bin) every time you use FTP. Note that binary is the default in noninteractive mode, when used with the url command-line parameter. See also ascii.


bye

End the FTP session, and if necessary, disconnect from the remote computer. The standard DOS exit and quit commands won't work here.


cd [ directory]

Change the working directory on the remote computer (to cd on the local machine, use ! cd or lcd).


close

Disconnect from the remote computer without exiting FTP. Use open to connect to a different FTP server or bye to exit FTP.


debug

Toggle debugging. When debugging is on, each internal command sent to the remote computer is displayed, preceded by the string --->. By default, debugging is off.


delete remote_file

Delete a file on the remote computer. Only a single file can be deleted at a time with delete (no wildcards are allowed); use mdelete to delete multiple files at once.


dir

Display a list of the contents of the working directory on the remote computer, with details. Use ls for a simple listing. Occasionally, directory listings for anonymous users may be disabled, in which case dir will not work; if you wish to download, you'll need to know the particular filename(s) beforehand.


disconnect

Same as close.


get remote_file [ local_file]

Transfer remote_file from the server to the local machine. If local_file is not specified, the local file will be given the same name as the original. The file will be placed in the local working directory; to choose a different destination, use lcd. Only a single file can be downloaded at a time with get (no wildcards are allowed); use mget to delete multiple files at once. If transferring binary (nontext) files, use the binary command first.


glob

Toggle filename "globbing." Globbing permits use of wildcard characters in local file or pathnames. By default, globbing is on. Globbing can also be disabled with the -g command-line parameter.


hash

Turn on or off FTP's crude progress bar for file transfers. A hashmark (#) character is displayed for each 2k of data transferred, so large files will have longer progress bars than small files. By default, hashmark printing is off.


help [ command]

Display all the available commands. Include command to get help with a single command (e.g., help get). Same as ?.


lcd [ directory]

Change the working directory on the local computer. Enter a full path as directory (e.g., c:\downloads) to effectively instruct FTP to place downloaded files there. Omit directory to simply display the current working directory. By default, the working directory is in use when FTP is started is used; if FTP is opened from Start Run, the working directory is c:\documents and settings\{username}.


literal command_line

Send so-called "arbitrary" commands to the remote FTP server (such as retr, stor, pasv, and port). A single FTP reply code is expected in return. Typical use of FTP does not involve using literal, but it can provide access to some advanced functions; among the more interesting is the ability to transfer files between two remote computers without having to first transfer them to the local machine.


ls

Display an abbreviated list of a remote directory's files and subdirectories. This is useful when a directory contains a lot of files. Type ls -1 (or use dir) to show the "long" listing, including file details. Occasionally, directory listings for anonymous users may be disabled, in which case ls will not work; if you wish to download, you'll need to know the particular filename(s) beforehand.


mdelete [ files]

Delete multiple files on remote computers. Unlike delete, wildcards can be used (e.g., *.txt for all .txt files).


mdir remote_files local_file

Store a listing of the remote working directory's contents (with details) into a file; both parameters are required. The remote_files parameter is used to modify the listing, either by specifying a wildcard (use * to list all files) or by specifying the name of another directory. local_file is the target filename in which the directory listing is stored.


mget remote_files

Transfer one or more remote files to the local computer. Unlike get, wildcards can be used (e.g., *.txt for all .txt files). You will be asked to confirm each transfer unless you turn off prompting with the prompt command. Local files will be given the same names as their remote counterparts. If transferring binary (nontext) files, use the binary command first.


mkdir directory

Create a remote directory. Note that anonymous users are usually not permitted to create directories on remote systems.


mls remote_dir local_file

Same as mdir, except that a short listing (no details) is stored.


mput local_files

Transfer one or more local files to the remote computer. Unlike put, wildcards can be used (e.g., *.txt for all .txt files). You will be asked to confirm each transfer unless you turn off prompting with the prompt command. Remote files will be given the same names as their local counterparts. If transferring binary (nontext) files, use the binary command first.


open hostname or IP address

Connect to the specified FTP server. This is the same as specifying a server in the FTP command line; use open if you omitted the host parameter. Open can be used whenever there's no current connection, either if you disconnected using disconnect or close or if the initial connection attempt was unsuccessful.


prompt

Turn on or off prompting for multiple file transfers. When you use the mput or mget commands, FTP will prompt you before transferring each file. By default, prompt is turned on; type prompt before using mput or mget to transfer multiple files without being prompted.


put local_file [ remote_file]

Transfers local_file from the local machine to the server. If remote_file is not specified, the remote file will be given the same name as the original. The file will be placed in the remote working directory; to choose a different destination, use cd. Only a single file can be uploaded at a time with put (no wildcards are allowed); use mput to delete multiple files at once. If transferring binary (nontext) files, use the binary command first.


pwd

Print Working Directory (PWD) displays the remote working directory; use cd to change to a different remote directory.


quit

End the ftp session with the remote computer and exit ftp.


quote [ command_line]

Same as literal.


recv remote_file [ local_file]

Same as get.


remotehelp [ command]

Display help for remote commands supported by the server. This is probably similar to the commands available on the client, but may not be identical. As with ? and help, supplying no arguments returns a list of command names. Use remotehelp command to get more info on each command.


rename from_name to_name

Rename a remote file. Note that anonymous users are usually not permitted to rename files on remote systems.


rmdir remote_directory

Delete a remote directory. Note that anonymous users are usually not permitted to delete directories on remote systems.


send local_file [ remote_file]

Same as put.


status

Display the current status of the connection and the current settings of options like prompt, verbose, and ascii|binary.


trace

Turn on or off packet tracing, which displays the route of each packet when executing an FTP command. By default, trace is off.


type [ type]

Display whether transfers are performed in binary or ascii mode. Use type binary (or just binary) to transfer binary files.


user username [ password]

Specify the username on the remote computer; if no password is specified, you will be prompted for one. Typically, FTP prompts for the username and password when a connection is first established; however, if you type an incorrect username and password, you can try again with the user command without having to reconnect.


verbose

Turn on or off verbose mode. If verbose is on (the default), all FTP responses are displayed, such as when a file transfer completes and any statistics regarding the efficiency of the transfer.

Examples

To copy the file preface.doc from the directory /pub/nutshell on a remote computer to \temp\docs on your local computer, once you're logged on to a server, you would perform the following from the DOS prompt (note that cd within ftp is for the remote computer):

C:\>cd \temp\docs 
C:\temp\docs>ftp 
						remote_computer 
						username 
						password 
ftp>binary 
ftp>cd /pub/nutshell 
ftp>get preface.doc 

Run a script containing ftp commands:

C:\>ftp -s:myfile.scr

This will load ftp and run myfile.scr, executing any ftp commands in the file.

Notes

  • Most web browsers support the ftp:// protocol, which provides limited FTP functionality without having to use an FTP client. For example, you can retrieve a single file from an anonymous FTP server by opening this address in any web browser: ftp://server.com/path/filename.ext.

  • Furthermore, you can specify a username and (optionally) a password, like this: ftp://username:password@server.com/path/filename.ext.

  • Some browsers will even let you upload files when connected to an FTP server (assuming the server permits you to do so). In Netscape 4.x, select "Upload File" from the File menu. In Internet Explorer, you can simply drag-drop files into an FTP window as though it were a folder on your hard disk.

  • All ftp command names can be abbreviated to the first four letters; sometimes fewer.

  • If any nonoptional arguments are omitted from most FTP commands, you'll be prompted for them.

  • When using the get or mget commands, transferred files will be placed in whatever directory was the working directory when you launched FTP. Once an FTP session has begun, you can change the working directory with the lcd command: to switch from the local C:\ to the A:\ drive, for example, you would type:

     ftp>lcd a:/

  • In FTP, to maintain consistency with its Unix heritage, you must use the forward slash (/) instead of the backslash (\) when specifying pathnames. Furthermore, directory and filenames are case sensitive when connecting to a Unix FTP server; readme.txt is a different file than Readme.TXT.

  • Many FTP servers impose an "idle timeout" on FTP connections; that is, if you open an FTP connection and let it sit for several minutes without typing any commands, the FTP server will disconnect you.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint