Internet File Transfer Program.
Syntax ftp [options] -u url file [...] Options May be specified at the command line, or to the ftp command interpreter. -n No `auto-login' upon initial connection. -o output When auto-fetching files, save the contents in output. output is parsed according to the FILE NAMING CONVENTIONS. If output is not `-' or doesn't start with `|', then only the first file specified will be retrieved into output; all other files will be retrieved into the basename of their remote name. -P port Sets the port number to port. -r wait Retry the connection attempt if it failed, pausing for wait seconds. -u url file [...] Upload files on the command line to url where url is one of the ftp URL types as supported by auto-fetch (with an optional target filename for single file uploads), and file is one or more local files to be uploaded. -v Enable verbose and progress. -V Disable verbose and progress.
Also see the ftp Advanced options page for further options.
The client host with which ftp is to communicate can be
specified on the command line. If this is done, ftp will immediately attempt
to establish a connection to an FTP server on that host; otherwise, ftp will
enter its command interpreter and await instructions from the user. When ftp
is awaiting commands from the user the prompt `ftp>' is provided to the user.
The following commands are recognized by ftp: account [passwd] Supply a supplemental password required by a remote system for access to resources once a login has been successfully completed. If no argument is included, the user will be prompted for an account password in a non-echoing input mode. append local-file [remote-file] Append a local file to a file on the remote machine. If remote-file is left unspecified, the local file name is used in naming the remote file after being altered by any ntrans or nmap setting. File transfer uses the current settings for type, format, mode, and structure. ascii Set the file transfer type to network ASCII. This is the default type. binary Set the file transfer type to support binary image transfer. bye Terminate the FTP session with the remote server and exit ftp. An end of file will also terminate the session and exit. case Toggle remote computer file name case mapping during mget commands. When case is on (default is off), remote computer file names with all letters in upper case are written in the local directory with the letters mapped to lower case. cd remote-directory Change the working directory on the remote machine to remote-directory. cdup Change the remote machine working directory to the parent of the current remote machine working directory. chmod mode remote-file Change the permission modes of the file remote-file on the remote system to mode. close Terminate the FTP session with the remote server, and return to the command interpreter. Any defined macros are erased. cr Toggle carriage return stripping during ascii type file retrieval. Records are denoted by a carriage return/linefeed sequence during ascii type file transfer. When cr is on (the default), carriage returns are stripped from this sequence to conform with the UNIX single linefeed record delimiter. Records on non-UNIX remote systems can contain single line- feeds; when an ascii type transfer is made, these linefeeds can be distinguished from a record delimiter only when cr is off. delete remote-file Delete the file remote-file on the remote machine. dir [remote-path [local-file]] Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent informa- tion that the server chooses to include; for example, most UNIX systems will produce output from the command `ls -l'. If remote-path is left unspecified, the current working directory is used. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving dir output. If no local file is specified, or if local-file is `-', the output is sent to the terminal. fget localfile Retrieve the files listed in localfile, which has one line per filename. form format Set the file transfer form to format. The default format is `file'. ftp host [port] A synonym for open. gate [host [port]] Toggle gate-ftp mode, which used to connect through the TIS FWTK and Gauntlet ftp proxies. This will not be permitted if the gate-ftp server hasn't been set (either explicitly by the user, or from the FTPSERVER environment variable). If host is given, then gate-ftp mode will be enabled, and the gate- ftp server will be set to host. If port is also given, that will be used as the port to connect to on the gate-ftp server. get remote-file [local-file] Retrieve the remote-file and store it on the local machine. If the local file name is not specified, it is given the same name it has on the remote machine, subject to alteration by the current case, ntrans, and nmap settings. The current settings for type, form, mode, and structure are used while transferring the file. glob Toggle filename expansion for mdelete, mget and mput. If globbing is turned off with glob, the file name arguments are taken literally and not expanded. Globbing for mput is done as in csh(1). For mdelete and mget, each remote file name is expanded separately on the remote machine and the lists are not merged. Expansion of a directory name is likely to be different from expansion of the name of an ordinary file: the exact result depends on the foreign operating system and ftp server, and can be previewed by doing `mls remote-files -' Note: mget and mput are not meant to transfer entire direc- tory subtrees of files. That can be done by transferring a tar(1) archive of the subtree (in binary mode). hash [size] Toggle hash-sign ('#') printing for each data block trans- ferred. The size of a data block defaults to 1024 bytes. This can be changed by specifying size in bytes. Enabling hash disables progress. help [command] Print an informative message about the meaning of command. If no argument is given, ftp prints a list of the known com- mands. lcd [directory] Change the working directory on the local machine. If no directory is specified, the user's home directory is used. lpwd Print the working directory on the local machine. ls [remote-path [local-file]] A synonym for dir. mdelete [remote-files] Delete the remote-files on the remote machine. mdir remote-files local-file Like dir, except multiple remote files can be specified. If interactive prompting is on, ftp will prompt the user to ver- ify that the last argument is indeed the target local file for receiving mdir output. mget remote-files Expand the remote-files on the remote machine and do a get for each file name thus produced. See glob for details on the filename expansion. Resulting file names will then be processed according to case, ntrans, and nmap settings. Files are transferred into the local working directory, which can be changed with `lcd directory'; new local directories can be created with `! mkdir directory'. mkdir directory-name Make a directory on the remote machine. mls remote-files local-file Like ls, except multiple remote files can be specified, and the local-file must be specified. If interactive prompting is on, ftp will prompt the user to verify that the last argu- ment is indeed the target local file for receiving mls out- put. mlsd [remote-path] Display the contents of remote-path (which should default to the current directory if not given) in a machine-parsable form, using MLSD. The format of display can be changed with `remopts mlst ...'. mlst [remote-path] Display the details about remote-path (which should default to the current directory if not given) in a machine-parsable form, using MLST. The format of display can be changed with `remopts mlst ...'. mode mode-name Set the file transfer mode to mode-name. The default mode is `stream' mode. modtime remote-file Show the last modification time of the file on the remote machine. more file A synonym for page. mput local-files Expand wild cards in the list of local files given as argu- ments and do a put for each file in the resulting list. See glob for details of filename expansion. Resulting file names will then be processed according to ntrans and nmap settings. msend local-files A synonym for mput. newer remote-file [local-file] Get the file only if the modification time of the remote file is more recent that the file on the current system. If the file does not exist on the current system, the remote file is considered newer. Otherwise, this command is identical to get. nlist [remote-path [local-file]] A synonym for ls. open host [port] Establish a connection to the specified host FTP server. An optional port number can be supplied, in which case, ftp will attempt to contact an FTP server at that port. If the auto-login option is on (default), ftp will also attempt to automatically log the user in to the FTP server (see below). page file Retrieve file and display with the program specified by the set pager option. passive [auto] Toggle passive mode (if no arguments are given). If auto is given, act as if FTPMODE is set to `auto'. If passive mode is turned on (default), ftp will send a PASV command for all data connections instead of a PORT command. The PASV command requests that the remote server open a port for the data con- nection and return the address of that port. The remote server listens on that port and the client connects to it. When using the more traditional PORT command, the client lis- tens on a port and sends that address to the remote server, who connects back to it. Passive mode is useful when using ftp through a gateway router or host that controls the direc- tionality of traffic. (Note that though FTP servers are required to support the PASV command by RFC 1123, some do not.) preserve Toggle preservation of modification times on retrieved files. progress Toggle display of transfer progress bar. The progress bar will be disabled for a transfer that has local-file as `-' or a command that starts with `|'. Refer to FILE NAMING CONVENTIONS for more information. Enabling progress disables hash. prompt Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selec- tively retrieve or store files. If prompting is turned off (default is on), any mget or mput will transfer all files, and any mdelete will delete all files. When prompting is on, the following commands are available at a prompt: a Answer `yes' to the current file, and automatically answer `yes' to any remaining files for the current command. n Answer `no', and do not transfer the file. p Answer `yes' to the current file, and turn off prompt mode (as if 'prompt off' had been given). q Terminate the current operation. y Answer `yes', and transfer the file. ? Display a help message. Any other reponse will answer `yes' to the current file. put local-file [remote-file] Store a local file on the remote machine. If remote-file is left unspecified, the local file name is used after process- ing according to any ntrans or nmap settings in naming the remote file. File transfer uses the current settings for type, format, mode, and structure. pwd Print the name of the current working directory on the remote machine. quit A synonym for bye. reget remote-file [local-file] reget acts like get, except that if local-file exists and is smaller than remote-file, local-file is presumed to be a par- tially transferred copy of remote-file and the transfer is continued from the apparent point of failure. This command is useful when transferring very large files over networks that are prone to dropping connections. rename [from [to]] Rename the file from on the remote machine, to the file to. reset Clear reply queue. This command re-synchronizes com- mand/reply sequencing with the remote FTP server. Resynchro- nization might be necessary following a violation of the FTP protocol by the remote server. rhelp [command-name] Request help from the remote FTP server. If a command-name is specified it is supplied to the server as well. rmdir directory-name Delete a directory on the remote machine. rstatus [remote-file] With no arguments, show status of remote machine. If remote-file is specified, show status of remote-file on remote machine. type [type-name] Set the file transfer type to type-name. If no type is specified, the current type is printed. The default type is network ASCII. usage command Print the usage message for command. user user-name [password [account]] Identify yourself to the remote FTP server. If the password is not specified and the server requires it, ftp will prompt the user for it (after disabling local echo). If an account field is not specified, and the FTP server requires it, the user will be prompted for it. If an account field is specified, an account command will be relayed to the remote server after the login sequence is completed if the remote server did not require it for logging in. Unless ftp is invoked with `auto-login' disabled, this process is done automatically on initial connection to the FTP server. verbose Toggle verbose mode. In verbose mode, all responses from the FTP server are displayed to the user. In addition, if verbose is on, when a file transfer completes, statistics regarding the efficiency of the transfer are reported. By default, verbose is on. xferbuf size Set the size of the socket send and receive buffers to size. ? [command] A synonym for help.
Command arguments which have embedded spaces can be quoted with quote " marks.
Commands which toggle settings can take an explicit on or off argument to
force the setting appropriately.
Commands which take a byte count as an argument (e.g., hash, rate, and
xferbuf) support an optional suffix on the argument which changes the
interpretation of the argument. Supported suffixes are:
b Causes no modification. (Optional) k Kilo; multiply the argument by 1024 m Mega; multiply the argument by 1048576 g Giga; multiply the argument by 1073741824
If ftp receives a SIGINFO (see the 'status' argument of stty(1)) or
SIGQUIT signal whilst a transfer is in progress, the current transfer
rate statistics will be written to the standard error output, in the same
format as the standard completion message.
AUTO-FETCHING FILES
In addition to standard commands, this version of ftp supports an auto-fetch feature. To enable auto-fetch, simply pass the list of host-names/files on the command line.
The following formats are valid syntax for an auto-fetch element:
[user@]host:[path][/] `Classic' FTP format.
If path contains a glob character and globbing is enabled, (see
glob), then the equivalent of `mget path' is performed.
If the directory component of path contains no globbing characters,
it is stored locally with the name basename (see basename(1)) of
path, in the current directory. Otherwise, the full remote name is
used as the local name, relative to the local root directory.
ftp://[user[:password]@]host[:port]/path[/][;type=X]
An FTP URL, retrieved using the FTP protocol if set ftp_proxy isn't
defined. Otherwise, transfer the URL using HTTP via the proxy
defined in set ftp_proxy. If set ftp_proxy isn't defined and user
is given, login as user. In this case, use password if supplied,
otherwise prompt the user for one.
In order to be compliant with RFC 1738, ftp strips the leading `/'
from path, resulting in a transfer relative from the default login
directory of the user. If the / directory is required, use a leading path of `%2F'. If a user's home directory is required (and
the remote server supports the syntax), use a leading path of
`%7Euser/'. For example, to retrieve /etc/motd from `localhost'
as the user `myname' with the password `mypass', use
`ftp://myname:mypass@localhost/%2fetc/motd'
If a suffix of `;type=A' or `;type=I' is supplied, then the transfer type will take place as ascii or binary (respectively). The
default transfer type is binary.
http://[user[:password]@]host[:port]/path
An HTTP URL, retrieved using the HTTP protocol. If set http_proxy
is defined, it is used as a URL to an HTTP proxy server. If HTTP
authorisation is required to retrieve path, and `user' (and optionally `password') is in the URL, use them for the first attempt to
authenticate.
file:///path
A local URL, copied from /path.
Unless noted otherwise above, and -o output is not given, the file is stored in the current directory as the basename(1) of path.
If a classic format or an FTP URL format has a trailing `/' or an empty
path component, then ftp will connect to the site and cd to the directory
given as the path, and leave the user in interactive mode ready for further input. This will not work if set ftp_proxy is being used.
Direct HTTP transfers use HTTP 1.1. Proxied FTP and HTTP transfers use
HTTP 1.0.
If -R is given, all auto-fetches that don't go via the FTP or HTTP proxies will be restarted. For FTP, this is implemented by using reget
instead of get. For HTTP, this is implemented by using the `Range:
bytes=' HTTP/1.1 directive.
If WWW or proxy WWW authentication is required, you will be prompted to
enter a username and password to authenticate with.
When specifying IPv6 numeric addresses in a URL, you need to surround the
address in square brackets. E.g.: `ftp://[::1]:21/'. This is because
colons are used in IPv6 numeric address as well as being the separator
for the port number.
ABORTING A FILE TRANSFER
To abort a file transfer, use the terminal interrupt key (usually Ctrl-C).
Sending transfers will be immediately halted.
FILE TRANSFER PARAMETERS
The FTP specification specifies many parameters which can affect a file
transfer. The type can be one of `ascii', `image' (binary),
`ebcdic', and `local byte size' (for PDP-10's and PDP-20's mostly).
ftp supports the ascii and image types of file transfer, plus local byte
size 8 for tenex mode transfers.
ftp supports only the default values for the remaining file transfer
parameters: mode, form, and struct.
Notes
Also see the ftp Advanced options page which
details:
"Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it" ~ Linus Torvalds
Related macOS commands:
getservbyname(3), editrc(5), services(5), ftpd(8)
curl - Transfer data from or to a server
FTP: Cyberduck - FTP client (free)
FTP: Panic Transmit - FTP client