Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftp(1) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ls(1)

sh(1)

tar(1)

ftpd(1M)

rcp(1N)

popen(3S)

netrc(4N)

ftp(1)  —  USER COMMANDS

NAME

ftp − file transfer program

SYNOPSIS

ftp [−dgintv] [hostname]

DESCRIPTION

The ftp command provides the user interface to the ARPANET standard File Transfer Protocol (FTP).  The program allows a user to transfer files to and from a remote network site. 

The 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 then await instructions from the user.  When ftp is awaiting commands from the user, it will display the prompt ftp>. 

OPTIONS

The following options may be specified at the command line, or to the command interpreter:

−d Enable debugging. 

−g Disable filename “globbing”. 

−i Turn off interactive prompting during multiple file transfers. 

−n Do not attempt auto-login upon initial connection.  If auto-login is not disabled, ftp will check the .netrc 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 login name of the account on the remote machine (the default is the login name on the local machine); if necessary, ftp will prompt for an account for the login and for a password. 

−t Enable packet tracing (currently not implemented). 

−v Show all responses from the remote server, as well as provide a report on data transfer statistics.  This is turned on by default if ftp is running interactively with its input coming from the user’s terminal. 

COMMANDS

The following commands can be specified to the command interpreter:

! [command [args ] ]
Run command as a shell command on the local machine.  If there are any arguments, the first is taken to be a command to execute directly, with the rest of the arguments as its arguments. 

$ macro-name [args]
Execute the macro macro-name that was defined with the macdef command.  Any arguments will be passed to the macro in “unglobbed” format. 

account [passwd]
Supply a supplemental password required by a remote system for access to its resources once a login has been completed successfully. 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 the local-file to a file on the remote machine.  If remote-file is not specified, the local file name will be used, subject to alteration by any ntrans or nmap setting.  The file transfer will use the current settings for type, format, mode, and structure. 

ascii Set the transfer type to “network ASCII”. 

bell Sound a bell after completing each file transfer command. 

binary
Set the type to support binary image transfers (the default value). 

bye Terminate the FTP session with the remote server and exit ftp.  An EOF condition will also terminate the session and exit. 

case Toggle the remote computer file name case mapping during mget commands.  When case is on (the default is off), the remote computer file names with all letters in “upper case” will be 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. 

close Terminate the FTP session with the remote server and return to the command interpreter.  Any defined macros will be erased. 

cr Toggle the “Carriage Return” stripping during “network ASCII” type file retrieval.  Each end-of-record is denoted by a CARRIAGE  RETURN/LINEFEED sequence during a “network ASCII” type file transfer.  When cr is on (the default setting), the CARRIAGE  RETURN characters are stripped from this sequence for consistency with the UNIX Operating System’s single LINEFEED record delimiter.  Records on non-UNIX-system remote hosts may contain single LINEFEED characters; during “network ASCII” type file transfers these LINEFEED characters may be distinguished from a record delimiter only when cr is off. 

delete remote-file
Delete the file remote-file on the remote machine. 

debug Toggle the debugging mode.  When debugging is on, ftp will print each command sent to the remote machine, preceded by the string −−>. 

dir [remote-directory] [local-file]
Print a listing of the directory contents in the directory remote-directory; optionally, place the output into local-file.  If no directory is specified, the current working directory on the remote machine will be used.  If no local file is specified (or if local-file is − ) the output will be sent to the terminal. 

disconnect
A synonym for close. 

form [format-name]
Set the file transfer form to format-name.  The default format is “file”

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 as that on the remote machine, subject to alteration by the current case, ntrans, and nmap settings.  The current settings for type, form, mode, and structure will be used while transferring the file. 

glob Toggle the filename expansion (“globbing”)  mechanism for mdelete, mget, and mput.  If “globbing” is turned off, the filenames are taken literally. 

“Globbing” for mput is done as in sh(1).  For mdelete and mget, each remote file name is expanded separately on the remote machine, but the lists are not merged. 

Expansion of a directory name is likely to be radically different from an expansion of the name of an ordinary file: the exact result depends on the remote operating system and on the FTP server; this action can be previewed by doing the following: mls remote-files −

hash Toggle the hash-sign (#) which will be printed for each data block transferred.  The size of a data block is 8192 bytes. 

help [command]
Print an informative message about the meaning of command.  If no argument is given, ftp will print a list of the known ftp commands. 

idle [seconds]
Sets the idle timer on the remote site to seconds. If no activity is performed for seconds then ftp times out and closes the connection.  The value of seconds must be between 30 and 7200.  If seconds is not specified idle displays the idle time limit on the remote side. 

lcd [directory]
Change the working directory on the local machine; if no directory is specified, the user’s home directory will be used. 

ls [remote-directory] [local-file]
Print an abbreviated listing of the contents of remote-directory on the remote machine.  The listing will include any system-dependent information which the server chooses to include: for example, most UNIX Operating Systems will produce output from the command “ls −l.  (See nlist) If the remote-directory argument is not specified, the current working directory will be 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 the ls output.  If local-file is not specified (or if local-file is −) the output will be sent to the terminal. 

macdef macro-name
Define a macro; all subsequent lines are stored as the macro macro-name until a null line (consisting of consecutive NEWLINE characters in a file or consecutive CARRIAGE_RETURN characters from the terminal) terminates the macro input mode.  There is a limit of 16 macros, as well as a maximum of 4096 characters per macro definition.  All macros will remain defined until a close command is executed. 

The macro processor interprets $ and \ as special characters.  A $ followed by a number (or numbers) will be replaced by the corresponding argument on the macro invocation command line.  A $ followed by an i signals to the macro processor that the executing macro is to be looped.  On the first pass $i will be replaced by the first argument on the macro invocation command line; on the second pass it will be 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 $ symbol. 

mdelete [remote-file]
Like delete, but multiple remote files may be specified.

mdir remote-file local-file
Like dir, but multiple remote files may be specified.  If interactive prompting is on, ftp will prompt the user to verify 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.] The resulting file names will then be processed according to the prevailing case, ntrans, and nmap settings.  The files will be transferred into the local working directory, which can be changed with lcd directory; new local directories can be created with ! mkdir new_directory. 

mkdir directory-name
Make a directory directory-name on the remote machine. 

mls remote-files local-file
Similar to ls(1), but multiple remote files may be specified.  If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving the mls output. 

mode [mode-name]
Set the “transfer mode” to mode-name.  The only valid mode-name is stream, which corresponds to the default “stream mode”.  This implementation only supports stream and requires that it be specified. 

modtime [remote-file]
Show the last modification time of the remote-file. 

mput local-files
Expand “wild cards” in the list of local-files given as arguments and do a put for each file in the resulting list.  [See glob for details of the filename expansion mechanism.] The resulting file names will then be processed according to the prevailing ntrans and nmap settings. 

newer remote-file [local-file]
Retrieve the remote-file if it is newer than the local-file.  If the local-file does not exist then the remote-file is retrieved.  If the local-file is not specified then a local file with the same name as remote-file is searched in the current directory of the local machine. 

nlist [remote-directory] [local-file]
Print a list of the name of files and directories in the remote-directory on the remote machine.  If the remote-directory argument is not specified, the current working directory will be 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 the nlist output.  If local-file is not specified (or if local-file is −) the output will be sent to the terminal. 

nmap [inpattern outpattern]
Enable (or disable) the filename mapping mechanism. If no arguments are specified, the filename mapping mechanism is unset. If any arguments are specified, the remote filenames will be mapped during the mput commands, as well as for put commands issued without a specified remote target filename.  If any arguments are specified, the local filenames will be mapped during mget commands, as well as for get commands issued without a specified local target filename. 

This command is useful when connecting to a non-UNIX-system remote host with different file naming conventions or practices.  The mapping follows the pattern set by inpattern and outpattern.  Here inpattern is a template for incoming filenames (which may have already been processed according to the ntrans and case settings).  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 will be treated literally and will be used to determine the variable values which correspond to nmap inpattern. 

For example, given the inpattern $1.$2 and the remote file name mydata.data, then $1 would have the value mydata and $2 would have the value data. 

Similarly, the outpattern determines the resulting mapped filename.  The sequence $1, $2, ..., $9 will be replaced by any value resulting from the inpattern template.  The sequence $0 will be replaced by the original filename.  In addition, the sequence “[seq1,seq2]” will be replaced by seq1 if seq1 is not a null string; otherwise it will be replaced by seq2. 

For example, assume that the command nmap $1.$2.$3 [$1,$2].[$2,file] is given.  Hence, for input filenames myfile.data and myfile.data.old this would yield the output filename myfile.data.  Similarly, the input filename myfile would generate output myfile.file; and finally, an input filename myfile would produce output myfile.myfile. 

The outpattern may include embedded SPACE characters, as in the example nmap $1 | sed "s/  ∗$//" > $1.  (Use the \ symbol to prevent special treatment of the “$”, “[”, “]”, and “,” symbols.) 

ntrans [inchars [outchars ] ]
Enable or disable the filename character translation mechanism. If no arguments are specified, the filename character translation mechanism is disabled. If arguments are specified, the characters in remote filenames are translated during mput commands, as well as for put commands issued without a specified remote target filename; characters in local filenames are translated during mget commands, as well as for get commands issued without a specified local target filename. 

This command is useful when connecting to a non-UNIX-system remote host 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 will be deleted from the file name. 

open host [port]
Establish a connection to the specified host FTP server.  If an optional port number is supplied, ftp will attempt to contact an FTP server at that port.  If the auto-login option is on (the default setting), ftp will also attempt to automatically log the user into the FTP server.  (See below)

prompt
Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to retrieve or store files selectively. By default, prompting is turned on. If prompting is turned off, any mget or mput command will transfer all files; any mdelete will delete all files. 

proxy ftp-command
Execute an FTP command on a secondary control connection.  This command allows the simultaneous connection to two remote FTP servers for transferring files between the two servers.  The first proxy command should be an open which should establish the secondary control connection.  Then enter the command proxy ? to see other FTP commands executable on the secondary connection. 

put local-file [remote-file]
Store a local-file on the remote machine.  If remote-file is not specified, the local-file name will be used after processing according to any prevailing ntrans or nmap settings for naming the remote-file.  The 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. 

quote arg1 arg2 ...
Send the specified arguments “verbatim” to the remote FTP server.  A single FTP reply code is expected in return.  (The rhelp command will display a list of valid arguments.) 

recv remote-file [local-file]
A synonym for get. 

reget remote-file [local-file]
Retrieve the remaining portion of a partially transferred file by restarting at the position indicated by the local-file size. The local-file is assumed to be the partially transferred file.  This command works like a restart bytecount command followed by the get remote-file [local-file] command, where bytecount is set to the size of the local-file. If local-file does not exist, reget terminates with an error message.  If the local-file is not specified, it is given the same name as that on the remote machine, subject to alteration by the current case, ntrans, and nmap settings.  The current settings for type, mode, and structure will be used while transferring the file. 

restart bytecount
Restart file transfer at bytecount. This command does not cause file transfer and should be immediately followed by a file transfer command.  restart causes the file transfer command to skip over the file to the specified bytecount. After the first file transfer following the restart command, the bytecount is reset to 0 for the subsequent file transfers. 

rhelp [command-name]
Request help from the remote FTP server.  If a command-name is specified, it is also supplied to the server. 

rstatus [file-name]
If no argument is given, show the status of the remote machine. If file-name is specified, show the status of file-name on the remote machine. 

rename [from-name] [to-name]
Rename the file from-name on the remote machine to the name to-name. 

reset Clear the reply queue: this command re-synchronizes the command/reply sequences with the remote FTP server.  Re-synchronization may be necessary as a result of detecting a violation of the FTP protocol by the remote server. 

rmdir directory-name
Delete directory-name on the remote machine. 

runique
Toggle the 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, then a .1 will be appended to this name.  If the resulting name matches another existing file, a .2 will be appended to the original name.  If this process continues up to .99, an error message will be printed and the file transfer will not occur.  The generated unique filename will be reported. 

send local-file [remote-file]
A synonym for put. 

sendport
Toggle the use of the PORT commands.  By default, ftp will attempt to use a PORT command when establishing a connection for each data transfer.  The use of the 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 when connected to certain FTP implementations that ignore PORT commands, but incorrectly indicate they have been accepted. 

site parameters
Send site specific command to remote server. The site specific commands supported by a remote server can be listed by using the rhelp site command. For the list of site specific commands supported by a remote site, see the man page for ftpd(1m) of the remote site. 

size file-name
Return the size of file-name on the remote machine. 

status
Show the current status of ftp. 

struct [struct-name]
Set the file transfer structure to struct-name.  By default stream is used, which corresponds to the default “file” structure.  The implementation only supports file and requires that it be specified. 

sunique
Toggle the storing of files on a remote machine under unique file names. The remote FTP server must support the ftp STOU command for successful completion.  The remote server will report the unique name.  The default value for sunique is off. 

system
Show the type of Operating System running on the remote machine.

tenex Set the “representation type” for talking to TENEX machines. 

trace Toggle packet tracing (currently not unimplemented). 

type [type-name]
Set the file transfer type
 to type-name.  If type-name is not specified, the current type will be printed.  The valid type-names are

    ascii for “network ASCII”
    binary or image for “image” (the default value), and
    tenex for “local byte size” with a byte size of 8 (used for talking to     TENEX machines).

user user-name [password] [account]
Identify yourself to the remote FTP server.  If the password is not specified, but 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 system will prompt the user 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 the verbose mode: In verbose mode, all responses from the FTP server will be displayed to the user.  In addition, if the verbose mode is enabled when a file transfer completes, statistics about the efficiency of the transfer will be reported.  By default, the verbose mode will be enabled if the ftp’s commands are coming from a terminal and disabled otherwise. 

? [command]
A synonym for help. 

THE .netrc FILE

The .netrc file contains login and initialization information for use by the auto-login process; this resides in the user’s home directory.  The following tokens will be recognized and may be separated by spaces, tabs, or new-lines:

machine name
Identify the name of a remote machine: The auto-login process will search the .netrc file for a machine token that matches the remote machine as specified in the ftp command line or as an argument to an open command.  Once a match has occurred, the subsequent .netrc tokens are processed until EOF is found or until another machine token is encountered. 

default
This is the same as machine name, except that default matches any name.  There can be only one default token and it must occur after all other machine tokens.  Normally, this is used as:

default login anonymous password user@site

This command line would give a user “automatic” anonymous ftp login privileges to machines not specified in .netrc.  The −n flag can be used to override this capability by disabling auto-login. 

login login-name
Identify a user on the remote machine. If this token is present, the auto-login process will initiate a login procedure using the specified login-name. 

password password-string
Supply a password for this login. If this token is present, the auto-login process will supply the specified password-string if the remote server requires a password as part of the login procedure. 

account account-string
Supply an additional account password. If this token is present, the auto-login process will supply the specified account-string if the remote server requires an additional account password; otherwise the auto-login process will initiate an ACCT command to solicit this input. 

macdef-name
Define a macro. This token functions like the ftp macdef command functions.  A macro will be defined for the specified macdef-name; its contents will begin with the next .netrc line and continue until a NULL line (consisting of consecutive new-line characters) is found.  If a macro named init is defined, it will be executed automatically as the last step of the auto-login process. 

ABORTING A FILE TRANSFER

To abort a file transfer, use the terminal interrupt key (usually ^C).  Sending transfers will be halted immediately; receiving transfers will be halted by sending an FTP protocol ABOR command to the remote server and then 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 some unexpected behavior by the remote server, including any 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

Local files specified as arguments to ftp commands will be processed according to the following rules. 

1) If the file name − is specified, the standard input (for reading) or standard output (for writing) will be used. 

2) If the first character of the file name is |, the remainder of the argument will be interpreted as a shell command.  ftp then will fork a shell, using popen(3S) with the argument supplied and read (write) from the standard output (standard input) of that shell.  If the shell command includes any embedded space characters, the argument must be quoted; for example, "| pg −n".  A particularly useful example of this mechanism is: "dir . | pg". 

3) Failing the above checks and if “globbing” is enabled, local file names will be expanded according to the rules used in the sh(1); see the glob command.  If the ftp command expects a single local file (for example, put), only the first filename generated by the “globbing” operation will be used. 

4) For mget commands and get commands with unspecified local file names, the local filename will be the remote filename, which may be altered by the prevailing case, ntrans, or nmap settings.  The resulting filename may be altered even further if runique is enabled. 

5) For mput commands and put commands with unspecified remote file names, the remote filename will be the local filename, which may be altered by a prevailing ntrans or nmap setting.  The resulting filename may be altered even further by the remote server if sunique is enabled. 

FILE TRANSFER PARAMETERS

The FTP specification specifies many parameters which may affect a file transfer.  For example, the type
 may be one of the following:

    “network ASCII”,
    “EBCDIC”,
    “image” (binary), or
    “local byte size” (normally with a specified byte size for PDP-10 and PDP-20 systems).

The “network ASCII” and “EBCDIC” types have a further subtype which specifies whether vertical format control data (i.e., NEWLINE characters, form feeds, etc.) is to be passed through (the “non-print” option), provides the TELNET format (i.e., “TELNET format controls”), or provides the ASA (FORTRAN) [“carriage control (ASA)”] format. 

ftp supports the “network ASCII” [subtype “non-print” only) and “image” types, as well as “local byte size” with a byte size of 8 for communicating with TENEX machines. 

ftp supports only the default values for the remaining file transfer parameters: mode, form, and structure. 

SEE ALSO

ls(1), sh(1), tar(1), ftpd(1M), rcp(1N), popen(3S), netrc(4N). 

USER CONSIDERATIONS

The correct execution of many commands will depend on the proper behavior by the remote server. 

An error in the treatment of CARRIAGE  RETURN symbols in the 4.2 BSD code handling transfers with a “representation type” of “network ASCII” has been corrected.  However, this correction may result in incorrect transfers of binary files to and from 4.2 BSD servers using a “representation type” of “network ASCII”.  Therefore avoid this problem by using the “image” type. 

NOTES

The mget and mput command options are not meant to transfer entire directory subtrees of files.  Instead, you can do this by transferring a tar(1) archive of the subtree (using a “representation type” of “image” as set by the binary command). 

The following commands behave differently when preceded by proxy:

•    open will not define new macros during the auto-login process,
•    close will not erase existing macro definitions,
•    get and mget will transfer files from the host on the primary control connection to the host on the secondary control connection
•    put, mput, and append will transfer files from the host on the secondary control connection to the host on the primary control connection. 

Third-party file transfers will depend on the support of the PASV command by the FTP server on the secondary control connection. 

quote should be utilized only by experienced users familiar with the FTP protocol. 

The runique capability will not affect local files generated from a shell command (see below).  The default value for runique is off. 

Any command argument containing embedded spaces should be surrounded by quote (") marks. 

If any non-optional command argument is not specified, ftp will prompt for that argument. 

If the password token is present in the .netrc file, ftp will abort this login procedure if the .netrc file is readable by anyone other than the user. 

  —  Internet Utilities

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026