FTP(1) BSD General Commands Manual FTP(1)
NAME
ftp − Internet file transfer program |
SYNOPSIS
ftp [−pinegvd] [host] |
pftp [−inegvd] [host] |
DESCRIPTION |
Ftp is the user interface to the Internet standard File Transfer Protocol. The program allows a user to transfer files to and from a remote network site. Options may be specified at the command line, or to the command interpreter. |
−p’ Use passive mode for data transfers. Allows use of ftp inenvironments where a firewall prevents connections from the outsideworld back to the client machine. Requires that the ftp serversupport the PASV command. This is the default now for all clients(ftp and pftp) due to security concerns using the PORT transfermode. The flag is kept for compatibility only and has no effectanymore.
−i’ Turns off interactive prompting during multiple file transfers. −n’ Restrains ftp from attempting ‘‘auto-login’’ upon initial connection. If auto-login is enabled, ftp will check the .netrc (see netrc(5)) file in the user’s home directory for an entry describing an account on the remote machine. If no entry exists, ftp will prompt for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompt for a password and an account with which to login. −e’ Disables command editing and history support, if it was compiled into the ftp executable. Otherwise, does nothing. −g’ Disables file name globbing. −m’ The default requires that ftp explicitly binds to the same interface for the data channel as the control channel in passive mode. Useful on multi-homed clients. This option disables this behavior. −v’ Verbose option forces ftp to show all responses from the remote server, as well as report on data transfer statistics. −d’ Enables debugging. The client host with which ftp is to communicate may 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: ! [command [args]] $ macro-name [args] account [passwd] append local-file [remote-file] ascii’ Set the file transfer type to network ASCII. This is the default type. bell’ Arrange that a bell be sounded after each file transfer command is completed. 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 cdup’ Change the remote machine working directory to the parent of the current remote machine working directory. chmod mode file-name 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 may contain single linefeeds; when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when cr is off. delete remote-file debug [debug-value] dir [remote-directory]
[local-file] disconnect form format get remote-file [local-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 directory subtrees of files. That can be done by transferring a tar(1) archive of the subtree (in binary mode). hash’ Toggle hash-sign (‘‘#’’) printing for each data block transferred. The size of a data block is 1024 bytes. help [command] idle [seconds] lcd [directory] ls [remote-directory]
[local-file] macdef macro-name mdelete [remote-files] mdir remote-files local-file mget remote-files mkdir directory-name mls remote-files local-file mode [mode-name] modtime file-name mput local-files newer file-name [local-file] nlist [remote-directory]
[local-file] nmap [inpattern outpattern] nmap $1.$2.$3 [$1,$2].[$2,file] would yield the output filename "myfile.data" for input filenames "myfile.data" and "myfile.data.old", "myfile.file" for the input filename "myfile", and "myfile.myfile" for the input filename ".myfile". Spaces may be included in outpattern, as in the example: ‘nmap $1 sed "s/ *$//" > $1’ . Use the ‘\’ character to prevent special treatment of the ‘$’,’[’,’[’, and ‘,’ characters. |
ntrans [inchars [outchars]]
Set or unset the filename character translation mechanism. If no arguments are specified, the filename character translation mechanism is unset. If arguments are specified, characters in remote filenames are translated during mput commands and put commands issued without a specified remote target filename. If arguments are specified, characters in local filenames are translated during mget commands and get commands issued without a specified local target filename. This command is useful when connecting to a non−UNIX remote computer with different file naming conventions or practices. Characters in a filename matching a character in inchars are replaced with the corresponding character in outchars. If the character’s position in inchars is longer than the length of outchars, the character is deleted from the file name. open host [port] prompt’ Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively 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. proxy ftp-command put local-file [remote-file] pwd’ Print the name of the current working directory on the remote machine. quit’ A synonym for bye. quote arg1 arg2 ... recv remote-file [local-file] reget remote-file [local-file] remotehelp [command-name] remotestatus [file-name] rename [from] [to] reset’ Clear reply queue. This command re-synchronizes command/reply sequencing with the remote ftp server. Resynchronization may be necessary following a violation of the ftp protocol by the remote server. restart marker rmdir directory-name runique’ Toggle storing of files on the local system with unique filenames. If a file already exists with a name equal to the target local filename for a get or mget command, a ".1" is appended to the name. If the resulting name matches another existing file, a ".2" is appended to the original name. If this process continues up to ".99", an error message is printed, and the transfer does not take place. The generated unique filename will be reported. Note that runique will not affect local files generated from a shell command (see below). The default value is off. send local-file [remote-file] sendport’ Toggle the use of PORT commands. By default, ftp will attempt to use a PORT command when establishing a connection for each data transfer. The use of PORT commands can prevent delays when performing multiple file transfers. If the PORT command fails, ftp will use the default data port. When the use of PORT commands is disabled, no attempt will be made to use PORT commands for each data transfer. This is useful for certain FTP implementations which do ignore PORT commands but, incorrectly, indicate they’ve been accepted. site arg1 arg2 ... size file-name status’ Show the current status of ftp. struct [struct-name] sunique’ Toggle storing of files on remote machine under unique file names. Remote ftp server must support ftp protocol STOU command for successful completion. The remote server will report unique name. Default value is off. system’ Show the type of operating system running on the remote machine. tenex’ Set the file transfer type to that needed to talk to TENEX machines. trace’ Toggle packet tracing. type [type-name] umask [newmask] user user-name [password]
[account] 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. ? [command] Command arguments which have embedded spaces may be quoted with quote ‘"’ marks. ABORTING A FILE TRANSFER |
To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transfers will be immediately halted. Receiving transfers will be halted by sending a ftp protocol ABOR command to the remote server, and discarding any further data received. The speed at which this is accomplished depends upon the remote server’s support for ABOR processing. If the remote server does not support the ABOR command, an ’ftp>’ prompt will not appear until the remote server has completed sending the requested file. The terminal interrupt key sequence will be ignored when ftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode may result from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol. If the delay results from unexpected remote server behavior, the local ftp program must be killed by hand. |
FILE NAMING CONVENTIONS
Files specified as arguments to ftp commands are processed according to the following rules. |
1. If the file name ’−’ is specified, the stdin (for reading) or stdout(for writing) is used.
2. If the first character of the file name is ’|’, the remainder of the argument is interpreted as a shell command. Ftp then forks a shell, using popen(3) with the argument supplied, and reads (writes) from the stdout (stdin). If the shell command includes spaces, the argument must be quoted; e.g. ‘‘" ls -lt"’’. A particularly useful example of this mechanism is: ‘‘dir more’’. 3. Failing the above checks, if ‘‘globbing’’ is enabled, local file names are expanded according to the rules used in the csh(1); c.f. the glob command. If the ftp command expects a single local file (.e.g. put), only the first filename generated by the "globbing" operation is used. 4. For mget commands and get commands with unspecified local file names, the local filename is the remote filename, which may be altered by a case, ntrans, or nmap setting. The resulting filename may then be altered if runique is on. 5. For mput commands and put commands with unspecified remote file names, the remote filename is the local filename, which may be altered by a ntrans or nmap setting. The resulting filename may then be altered by the remote server if sunique is on. FILE TRANSFER PARAMETERS |
The FTP specification specifies many parameters which may affect a file transfer. The type may 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. |
ENVIRONMENT
Ftp utilizes the following environment variables. |
HOME’ For default location of a .netrc file, if one exists.
SHELL’ For default shell. SEE ALSO |
ftpd(8), RFC 959 |
HISTORY
The ftp command appeared in 4.2BSD. |
BUGS
Correct execution of many commands depends upon proper behavior by the remote server. An error in the treatment of carriage returns in the 4.2BSD ascii-mode transfer code has been corrected. This correction may result in incorrect transfers of binary files to and from 4.2BSD servers using the ascii type. Avoid this problem by using the binary image type. Linux NetKit (0.17) August 15, 1999 Linux NetKit (0.17) |