FTP(1C) NAME ftp - file transfer program SyNOPSIS fftp [ -v ] [ -d ] [ -i ] [ -n ] [ -g ] [ host ] DESCRIPTION fftp is the user interface to the DARPA File Transfer Protocol. The pro- gram transfers files to and from a remote network site. For file transfers between 4.2 and 4.3 UNIX-based hosts on a local network, rcp is preferable. The client host with which fftp is to communicate can be specified on the command line. In this case, fftp immediately attempts to establish a con- nection to an FTP server on that host; otherwise, fftp enters its command interpreter and waits for instruction, displaying the prompt ``ftp>''. ftp recognizes the following commands: ! Invoke a shell on the local machine. $ macroname [ args ] Execute the macro macroname that was defined with the macdef command. Arguments are passed to the macro unglobbed. account [ passwd ] Supply a supplemental password required by a remote system for access to resources once a login has been successfully com- pleted. If no argument is included, the user will be prompted for an account password in a non-echoing input mode. append localfile [ remotefile ] Append a local file to a file on the remote machine. If remotefile is left unspecified, the local file name is used to name the remote file. File transfer uses the current set- tings for type, format, mode, and structure. ascii Set the file transfer type to network ASCII. This is the default. bell Sound a bell 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 fftp. case Toggle remote computer file name case-mapping during mget com- mands. 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 remotedir Change the working directory on the remote machine to remotedir. cdup Change the remote machine working directory to its parent. FTP(1C) close Terminate the FTP session with the remote server, and return to the command interpreter. 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 linefeeds; when an ASCII type transfer is made, these linefeeds can be distinguished from a record delimiter only when cr is off. debug [ debugvalue ] Toggle debugging mode. If an optional debugvalue is speci- fied, it is used to set the debugging level. When debugging is on, fftp prints each command sent to the remote machine, pre- ceded by the string --> . delete remotefile Delete the file remotefile on the remote machine. dir [ remotedir ] [ localfile ] Print the contents of directory, remotedir, and, optionally, place the output in localfile. If no directory is specified, the current working directory on the remote machine is used. If no local file is specified, output comes to the terminal. disconnect A synonym for close. form format Set the file transfer form to format. The default format is ``file''. get remotefile [ localfile ] Retrieve the remotefile 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. The current settings for type, form, mode, and structure are used while transferring the file. glob Toggle file name globbing. With file name globbing enabled, each local file or pathname is processed for csh metacharac- ters. These characters are * ? [] ~ {}. Remote files speci- fied in multiple item commands, such as mput, are globbed by the remote server. With globbing disabled, all files and path- names are treated literally. 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. 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 2 UMAX 4.3 User's Reference Manual FTP(1C) exact result depends on the foreign operating system and FTP server, and can be previewed by doing ``mls remotefiles''. Note: mget and mput are not meant to transfer entire directory subtrees of files. That can be done by transferring a tar archive of the subtree (in binary mode). hash Toggle number-sign (#) printing for each data block transferred. The size of a data block is 1024 bytes. help command Print a description of command. With no argument, fftp prints a list of the known commands. lcd [ dir ] Change the working directory dir on the local machine. If dir is not specified, change to the user's home directory. ls [ remotedir ] [ localfile ] Print an abbreviated listing of the contents of a directory on the remote machine. If remotedir is left unspecified, the current working directory is used. If no local-file is speci- fied, the output is sent to the terminal. macdef macroname Define a macro. Subsequent lines are stored as the macro macroname; a null line (consecutive newline characters in a file or carriage returns from the terminal) terminates macro input mode. There is a limit of 16 macros and 4096 total characters in all defined macros. Macros remain defined until a close command is executed. The macro processor interprets $ and \\\ as special characters. A $ followed by a number (or numbers) is replaced by the corresponding argument on the macro invocation command line. A $ followed by an i signals that macro processor that the executing macro is to be looped. On the first pass $i is replaced by the first argument on the macro invocation command line, on the second pass it is replaced by the second argument, and so on. A \\\ followed by any character is replaced by that character. Use the \\\ to prevent special treatment of the $. mdelete remotefiles Delete the specified files on the remote machine. If globbing is enabled, the remote file specification is first expanded using ls. mdir remotefiles localfile Obtain a directory listing of multiple files on the remote machine and place the result in localfile. mget remotefiles Retrieve the specified files from the remote machine and place them in the current local directory. If globbing is enabled, the specification of remote files will first be expanded using ls. mkdir dirname UMAX 4.3 User's Reference Manual 3 FTP(1C) Make a directory named dirname on the remote machine. mls remotefiles localfile Obtain an abbreviated listing of multiple files on the remote machine and place the result in localfile. mode [ modename ] Set the file transfer mode to modename. The default mode is stream. mput localfiles Expand wildcards in the list of local files given as arguments and do a put for each file in the resulting list. This transfers multiple local files from the current local direc- tory to the current working directory on the remote machine. See csh for details of filename expansion. Resulting file names will then be processed according to ntrans and nmap set- tings. nmap [ inpattern outpattern ] Set or unset the filename mapping mechanism. If no arguments are specified, the filename mapping mechanism is unset. If arguments are specified, remote filenames are mapped during mput commands and put commands issued without a specified remote target filename. If arguments are specified, local filenames are mapped during mget commands and get commands issued without a specified local target filename. This com- mand is useful when connecting to a non-UNIX remote computer with different file naming conventions or practices. The map- ping follows the pattern set by inpattern and outpattern. inpattern is a template for incoming filenames (which may have already been processed according to the ntrans and case set- tings). Variable templating is accomplished by including the sequences ``$1'', ``$2'', ..., ``$9'' in inpattern. Use \\\ to prevent this special treatment of the $ character. All other characters are treated literally, and are used to determine the nmap inpattern variable values. For example, given inpat- tern $1.$2 and the remote file name mydata...data, $1 would have the value ``mydata'', and $2 would have the value ``data''. The outpattern determines the resulting mapped filename. The sequences ``$1'', ``$2'', ...., ``$9'' are replaced by any value resulting from the inpattern template. The sequence ``$0'' is replace by the original filename. Additionally, the sequence [seq1,seq2] is replaced by seq1 if seq1 is not a null string; otherwise it is replaced by seq2. For example, the command ``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 can be included in outpattern, as in the example: nmap $1 |sed "s/ *$//" > $1 . Use the \\\ character to prevent spe- cial treatment of ``$'', ``['', ``]'', and ``,''. ntrans [ inchars [ outchars ] ] FTP(1C) 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 dif- ferent 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 posi- tion in inchars is longer than the length of outchars, the character is deleted from the file name. open host [ port ] Establish a connection to the specified host's FTP server. An optional port number can be supplied, in which case, fftp attempts to contact an FTP server at that port. If the auto- login option is on (default), fftp also attempts to automati- cally log the user in to the FTP server (see below). 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), any mget or mput transfers all files. proxy ftpcommand Execute an FTP command on a secondary control connection. This command allows simultaneous connection to two remote FTP servers for transferring files between the two servers. The first proxy command should be an open, to establish the secon- dary control connection. Enter the command ``proxy ?'' to see other FTP commands executable on the secondary connection. The following commands behave differently when prefaced by proxy: open will not define new macros during the auto-login process, close will not erase existing macro definitions, get and mget transfer files from the host on the primary control connection to the host on the secondary control connection, and put, mput, and append transfer files from the host on the secondary control connection to the host on the primary con- trol connection. Third-party file transfers depend upon sup- port of the FTP protocol PASV command by the server on the secondary control connection. put localfile [ remotefile ] Store a local file on the remote machine. If remotefile is left unspecified, the local file name is used 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... UMAX 4.3 User's Reference Manual 5 FTP(1C) quote arg1 arg2 ... The arguments specified are sent, verbatim, to the remote FTP server. A single FTP reply code is expected in return. recv remotefile [ localfile ] A synonym for get. remotehelp [ commandname ] Request help from the remote FTP server. If a commandname is specified, it is supplied to the server as well. rename [ from ] [ to ] Rename, on the remote machine, the file from to the file to. reset Clear reply queue. This command resynchronizes command/reply sequencing with the remote FTP server. Resynchronization may be neccesary following a violation of the FTP protocol by the remote server. rmdir dirname Delete the directory dirname on the remote machine. 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 localfile [ remotefile ] A synonym for put. sendport Toggle the use of PORT commands. By default, fftp attempts to use a PORT command when establishing a connection for each data transfer. If the PORT command fails, fftp uses the default data port. When the use of PORT commands is disabled, no attempt is made to use them for each data transfer. This is useful for certain FTP implementations that do ignore PORT commands but wrongly indicate they have been accepted. status Show the current status of fftp. struct [ structname ] Set the file transfer structure to structname. The default structure is stream. sunique Toggle storing of files on remote machine under unique file names. Remote FTP server must support FTP protocol STOU com- mand for successful completion. The remote server will report unique names. Default value is off. tenex Set the file transfer type to that needed to talk to TENEX FTP(1C) machines. trace Toggle packet-tracing. type [ typename ] Set the file transfer type to typename. If no type is speci- fied, the current type is printed. The default type is network ASCII. user username [ password ] [ account ] Identify yourself to the remote FTP server. If the password is not specified and the server requires it, fftp prompts the user for it (after disabling local echo). If an account field is not specified, and the FTP server requires it, the user is prompted for it. Unless fftp is invoked with ``auto-login'' disabled, this process is done automatically on initial con- nection 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 mode is on, when a file transfer completes, statistics regard- ing the efficiency of the transfer are reported. By default, verbose is on. ??? [ command ] A synonym for help. Command arguments that have embedded spaces can be quoted with double quote (") marks. ABORTING A FILE TRANSFER To abort a file transfer, use the terminal interrupt key (usually CTRL- C). Sending transfers are immediately halted. Receiving transfers are halted by sending an FTP protocol ABOR command to the remote server, and discarding any further data received. The speed at which this is accom- plished 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 is ignored when fftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode can result from the ABOR processing described above, or from unexpected behavior by the remote server, including vio- lations 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 -, the standard input (for reading) or the stan- dard output (for writing) is used. 2. If the first character of the file name is a bar(|), the remainder of the argument is interpreted as a shell command. fftp then forks a FTP(1C) shell, using popen with the argument supplied, and reads (writes) from the stdout (stdin). If the shell command includes spaces, the argument must be quoted; for example, """||| ls -lt""". A particularly use- ful 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 csh; see the glob com- mand. 4. For mget commands and get commands with unspecified local file names, the local filename is the remote filename, which can be altered by a case, ntrans, or nmap setting. The resulting filename can 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 can be altered by a ntrans or nmap setting. The resulting filename can then be altered by the remote server if sunique is on. FILE TRANSFER PARAMETERS The FTP specification identifies many parameters that 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). fftp supports the ASCII and image types of file transfer, plus local byte size 8 for tenex mode transfers. fftp supports only the default values for the remaining file transfer parameters: mode, form, and struct. OPTIONS Options can be specified at the command line, or to the command inter- preter. -d Enable debugging. -g Disable file name globbing. -i Turn off interactive prompting during mutiple file transfers. -n Restrain fftp from attempting auto-login upon initial connection. If auto-login is enabled, fftp checks the ...netrc file in the user's home directory for an entry describing an account on the remote machine. If no entry exists, fftp prompts for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompts for a password and an account with which to log-in. -v Force fftp to show all responses from the remote server and to report data transfer statistics. THE .netrc FILE The ...netrc file contains login and initialization information used by the auto-login process. It resides in the user's home directory. The following identifiers are recognized; they can be separated by spaces, tabs, or newlines. FTP(1C) machine name Identify a remote machine name. The auto-login process searches the ...netrc file for a machine identifier that matches the remote machine specified on the FTP command line or as an open command argument. Once a match is made, the subsequent ...netrc identifiers are pro- cessed, stopping when the end-of-file is reached or another machine identifier is encountered. login name Identify a user on the remote machine. If this identifier is present, the auto-login process initiates a login using the specified name. password string Supply a password. If this identifier is present, the auto-login process supplies the specified string if the remote server requires a password as part of the login process. Note that if this identifier is present in the ...netrc file, fftp aborts the auto-login process if the ...netrc is readable by anyone besides the user. FTP(1C) account string Supply an additional account password. If this identifier is present, the auto-login process supplies the specified string if the remote server requires an additional account password, or the auto- login process initiates an ACCT command if it does not. macdef name Define a macro. This identifier functions like the FTP macdef com- mand functions. A macro is defined with the specified name; its con- tents begin with the next ...netrc line and continue until a null line (consecutive newline characters) is encountered. If a macro named init is defined, it is automatically executed as the last step in the auto-login process. SEE ALSO csh(1), rcp(1) ftpd(8c) in the UMAX 4.3 System Administrator's Reference Manual RESTRICTIONS Many FTP server implementations do not support the experimental opera- tions such as print working directory. Aborting a file transfer does not work right; if one attempts this, the local FTP will probably have to be killed by hand. 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 UNIX ASCII -mode transfer code has been corrected. This correction can 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.