QNX Developer Support

Home
Developer Resources
Developer Support
PDF Documents
[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

ftp

ARPANET file transfer program (UNIX)

Syntax:

ftp [-AadFginptVv] 
    [-P port] [-r wait] [-T dir,max[,inc]]
    [[user@]host [port]] 
    [user@]host:[path][/] 
    [file:///path]
    [ftp://[user[:password]@]host[:port]/path[/]]

ftp -u url file [...]

Options:

-A
Always use an active connection. By default, ftp tries to use active-mode; it's useful for connecting to very old servers that don't implement passive-mode (-p) properly.
-a
Bypass normal login procedure, and use an anonymous login instead.
-d
Enable debugging.
-F
Allow clients to access non-regular files. You can only operate on files that are not considered regular files, e.g. named special files under /dev/shmem (see S_ISREG under stat()).
-g
Disable filename globbing.
-i
Don't perform interactive prompting during multiple file transfers.
-n
Don't attempt "autologin" on initial connection.

If autologin is enabled, ftp checks the .netrc file (see "the .netrc file," below) in your home directory for an entry describing an account on the remote machine.

If no entry exists, ftp prompts for the login name of the remote machine (default is the user ID on the local machine) and, if necessary, for a password and an account.

-P port
Set the port number.
-p
Enable passive-mode operations for use behind connection filtering firewalls. By default, ftp tries to use active-mode (see -A).
-r wait
Retry the connection attempt if it fails, pausing for wait seconds.
-T direction,maximum[,increment]
Set the maximum transfer rate for the direction to maximum bytes/second, and if specified, the increment to increment bytes/second. See rate for more detailed information.
-t
Enable packet tracing.
-u url file [...]
Upload files on the command line to url, where:
  • url is a format supported by auto-fetch (with an optional target filename for single file uploads). See "Auto-fetching files" for valid formats.
  • file is one or more local files to be uploaded.
-V
Disable verbose and progress, overriding the default of enabled when output is to a terminal.
-v
Enable verbose and progress; show all responses from the remote server and report on data-transfer statistics. This is the default if the output is sent to a terminal (and, in the case of progress, ftp is the foreground process).

Description:

The ftp utility is the user interface to the ARPANET-standard File Transfer Protocol. With this utility, you can transfer files to and from a remote network site.

If you use the following form:

ftp -u url file [...]

a file is fetched using the FTP protocol, or by direct copying into the current directory. This is ideal for scripts. See "Auto-fetching files" for more information.

When you invoke ftp from the command line, you can specify the host that ftp is to communicate with. If you do, ftp immediately attempts to establish a connection to an FTP server on that host. If you don't specify a host, ftp enters its command interpreter, displays the ftp> prompt, and waits for you to enter commands.

Commands

The following pages contain several references to commands that are represented in uppercase (e.g. PORT, SITE); these are FTP server commands. For more information on these commands, see ftpd.

If a command's arguments have embedded spaces, you can quote the arguments with double quotes (").

The ftp utility recognizes the following commands:

! [command [args]]
Invoke an interactive shell on the local machine. If you supply arguments, the first is executed as a command and the rest are taken as its arguments.
$ macroname [args]
Execute the macro macroname that was defined with the macdef command. Arguments are passed to the macro unglobbed.
account [passwd]
Once a login has successfully completed, supply a supplemental password; this password is required by the remote system for access to resources. If you omit the password, you're prompted for an account password with echoing turned off.
append local_file [remote_file]
Append a local file to a file on the remote machine. If you omit remote_file, the local filename 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. Use this file transfer type when you're transferring text files between systems that use a different end-of-line character (such as DOS and UNIX).
bell
Ring 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 ftp. An end-of-file (Ctrl-D) also terminates the session and exits.
case
Toggle the remote-computer filename case mapping during mget commands. When case is on (default is off), remote computer filenames with all letters in uppercase are written in the local directory with the letters mapped to lowercase.
cd remote_directory
Change the working directory on the remote machine to the specified directory.
cdup
Change the remote machine's working directory to its parent directory.
chmod mode remote_file
Change the permission modes of 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 (default is on). During ASCII-type file transfer, records are denoted by a carriage return/linefeed sequence. By default, these carriage returns are stripped 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 record delimiters only when cr is off.

debug [debug_value]
Toggle debugging mode (default is off). If an optional debug_value is specified, it's used to set the debugging level. When debugging is on, ftp prints each command sent to the remote machine, preceded by the string "-->".
delete remote_file
Delete the specified file on the remote machine.
dir [remote_directory [local_file]]
Print a listing of the directory contents in the remote_directory; or place the output in local_file, if specified. The listing includes any system-dependent information that the server chooses to include; for example, most systems produce output from the command ls -l.

If interactive prompting is on (see prompt), ftp prompts you to verify that the last argument is indeed the target local file for receiving dir output. If you omit remote_directory, the contents of the current working directory on the remote machine are printed. If you omit local_file, or if you specify it as -, output goes to the terminal.

disconnect
A synonym for close.
epsv4
Enable (the default) or disable the use of the extended EPSV and EPRT commands on IPv4 connections; first try EPSV/EPRT, and then PASV/PORT. If an extended command fails, then this option is temporarily disabled for the duration of the current connection, or until epsv4 is executed again.
exit
A synonym for bye.
fget localfile
Retrieve the files listed in localfile, which has one line per filename.
form format
Set the file transfer form to format (default format is file).
ftp host [port]
A synonym for open.
gate [host [port]]
Connect or disconnect through the TIS FWTK and Gauntlet FTP proxies. Toggling the mode isn't permitted if the gate-ftp server hasn't been set (either explicitly by the user, or by the FTPSERVER environment variable). If host is specified, the gate-ftp mode is enabled and the gate-ftp server is set to host. If port is specified, it's 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 you omit local_file, the file 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, format, mode, and structure are used while transferring the file.
glob
Toggle filename expansion for mdelete, mget, and mput (default is on). If globbing is turned off with glob, the filename arguments are taken literally and not expanded. Globbing for mput is done as in the shell. For mdelete and mget, each remote filename is expanded separately on the remote machine and the lists aren't merged.

Expansion of a directory name is likely to differ from expansion of the name of a regular file -- the exact result depends on the remote operating system and FTP server. You can preview the result by doing:

mls remote_files -
    

Note that mget and mput aren't meant to transfer entire directory subtrees of files. You can do this by transferring a tar archive of the subtree (in binary mode).

hash [size]
Toggle hash-sign (#) printing for each data block transferred. The size of a data block is 1024 bytes (the default), or size bytes. Enabling hash disables progress.
help [command]
Print the meaning of command. If you omit command, ftp prints a list of the known commands.
idle [seconds]
Set the inactivity timer on the remote server to the specified number of seconds. If you omit seconds, the current inactivity timer is printed.
image
A synonym for binary.
lcd [directory]
Change the working directory on the local machine. If you omit directory, your home directory is used.
less file
A synonym for page.
lpage local_file
Display the local_file with the program specified by the set pager option.
lpwd
Print the working directory on the local machine.
ls [remote_directory] [local_file]
A synonym for dir.
macdef macro_name
Define a macro. Subsequent lines are stored as the macro macro_name. A null line (consecutive newline characters in a file or carriage returns from the terminal) terminates macro input mode. There's 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 tells the 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's 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 $.

To execute a macro, use the $ macroname command.

mdelete [remote_files]
Delete the specified remote files on the remote machine.
mdir remote_file... local_file
Like dir, except you can specify multiple remote files. If interactive prompting is on, ftp prompts you 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 filename that's produced. (See glob for details on the filename expansion.) Resulting filenames are processed according to case, ntrans and nmap settings. Files are transferred into the local working directory, which you can change using "lcd directory" and you can create new local directories with "! mkdir directory".
mkdir directory_name
Make a directory on the remote machine.
mls remote_file... local_file
Like ls, except you must specify multiple remote files and the local file. If interactive prompting is on, ftp prompts you to verify that the last argument is indeed the target local file for receiving mls output.
mode [mode_name]
Set the file transfer mode to the specified mode (default is stream mode).
modtime remote_file
Show the last modification time of this remote file.
more file
A synonym for page.
mput local_files
Expand wildcards 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 filename expansion.) Resulting filenames are processed according to ntrans and nmap settings.
msend local_files
A synonym for mput.
newer remote_file [local_file]
Get the remote file only if it's been modified more recently than the corresponding file on the current system. If the file doesn't exist on the current system, the remote file is considered newer. Otherwise, this command is identical to get.
nlist [remote_directory] [local_file]
A synonym for ls.
nmap [inpattern outpattern]
Set or unset the filename mapping mechanism. If arguments aren't specified, the filename mapping mechanism is unset.

If you supply arguments, remote filenames are mapped during any mput and put commands that have been issued without a specified remote target filename. In addition, local filenames are mapped during any mget and get commands that have been issued without a specified local target filename.

The nmap command is useful when connecting to a non-UNIX remote computer that uses different file naming conventions or practices.

The mapping follows the pattern set by inpattern and outpattern.

The inpattern template is for incoming filenames (which may have already been processed according to the ntrans and case settings). To do variable templating, include 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 inpattern $1.$2 and the remote filename mydata.data, $1 has the value mydata and $2 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 replaced by the original filename. Additionally, the sequence [seq1, seq2] is replaced by [seq1] if seq1 isn't a null string; otherwise, it's replaced by seq2. For example, this command:

nmap $1.$2.$3 [$1,$2].[$2,file]
    

yields these mapped filenames:

Input filename: Output filename:
myfile.data

myfile.data.old

myfile.data
myfile myfile.file
.myfile myfile.myfile

You can include spaces in outpattern, as in this example:

nmap $1 sed "s/ *$//" > $1
    

Use the \ character to prevent special treatment of these characters:

$  [ ] ,
    
ntrans [inchars [outchars]]
Set or unset the mechanism for translating filename characters. If you don't supply arguments, the mechanism is unset.

If you do specify arguments, characters in remote filenames are translated during any mput and put commands that have been issued without a specified remote target filename. In addition, characters in local filenames are translated during any mget and get commands that have been issued without a specified local target filename.

The ntrans command is useful when connecting to a non-UNIX remote computer that uses different file naming conventions or practices. Characters in a filename matching a character in inchars are replaced with the corresponding character in outchars.

If a character's position in inchars is longer than the length of outchars, the character is deleted from the filename. For example, if you specify ntrans abc de as the translation, the character c is deleted.

open host [port]
Establish a connection to the specified host FTP server. If you supply a port number, ftp attempts to contact an FTP server at that port. If the autologin option is on (the default), ftp also attempts to automatically log you in (see "the .netrc file").
page file
Retrieve the specified file and display it with the program specified by the set pager option.
passive [auto]
Toggle passive mode (if no arguments are given). If auto is specified, act as if FTPMODE is set to "auto". If passive-mode is turned on (default), ftp sends 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 connection 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 listens 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 directionality of traffic. (Note that though FTP servers are required to support the PASV command by RFC 1123, some don't.)
pdir [remote_directory]
Perform dir [remote_directory], and display the result with the program specified by the set pager option.
pls [remote_directory]
Perform ls [remote_directory], and display the result with the program specified by the set pager option.
preserve
Toggle the preservation of modification times on retrieved files.
progress
Toggle the display of the transfer progress bar. The progress bar is disabled for a transfer that has local_file as - or for a command that starts with |. See "How filenames are processed" for more information. Enabling progress disables hash.
prompt
Toggle interactive prompting (default is on). Interactive prompting occurs during multiple file transfers so that you can selectively retrieve or store files. If prompting is turned off, any mget or mput transfers all files, and any mdelete deletes 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 don't transfer the file.
p
Answer "yes" to the current file, and turn off prompt mode (as is "prompt off" is specified).
q
Terminate the current operation.
y
Answer "yes," and transfer the file.
?
Display a help message.

Any other response answers "yes" to the current file.

proxy ftp_command
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 secondary 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 doesn't define new macros during the autologin process.
  • close doesn't 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.
  • put, mput, and append transfer files from the host on the secondary control connection to the host on the primary control connection.

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

put local_file [remote_file]
Store a local file on the remote machine. If you omit remote_file, the local filename is used after processing 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 remote machine's current working directory.
quit
A synonym for bye.
quote arg1 arg2 ...
Take the supplied arguments and send them verbatim to the remote FTP server.
rate direction [maximum [increment]]
Throttle the maximum transfer rate to maximum bytes/second. If maximum is 0, disable the throttle.

Valid options for direction are:

all
Both directions.
get
Incoming transfers.
put
Outgoing transfers.

You can modify maximum on the fly by increment bytes (default is 1024) each time a given signal is received:

SIGUSR1
Increment maximum by increment bytes.
SIGUSR2
Decrement maximum by increment bytes. The result must be a positive number.

If maximum isn't specified, the current throttle rates are displayed. Note that rate isn't implemented yet for ASCII-mode transfers.

rcvbuf size
Set the size of the socket receive buffer. This command isn't supported by the tiny stack (npm-ttcpip.so).
recv remote_file [local_file]
A synonym for get.
reget remote_file [local_file]
The reget command acts like get, except that if local_file exists and is smaller than remote_file, local_file is presumed to be a partially 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 the reply queue. This command, which resynchronizes command/reply sequencing with the remote FTP server, may need to be executed following a violation of the FTP protocol by the remote server.
restart marker
Restart the immediately subsequent get or put at the indicated marker, which is usually a byte offset into the file.
rhelp [command_name]
Request help from the remote FTP server. If you specify a command, it's supplied to the server as well.
rmdir directory_name
Delete a directory on the remote machine.
rstatus [filename]
Show the status of the remote machine; or if specified, the status of filename on the remote machine.
runique
Toggle the storing of files on the local system with unique filenames (default is off). 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 doesn't take place. The generated unique filename is reported. Note that runique doesn't affect local files generated from a shell command (see "How filenames are processed")
send local_file [remote_file]
A synonym for put.
sendport
Toggle the use of PORT commands. By default, ftp attempts 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 uses the default data port.

When the use of PORT commands is disabled, no attempt is made to use PORT commands for each data transfer. This is useful for certain FTP implementations that ignore PORT commands but incorrectly indicate they've been accepted.

set [option value]
Set option to value. If no arguments are specified, display all of the options and their values. Currently, the supported options are:
anonpass
Defaults to $FTPANONPASS.
ftp_proxy
Defaults to $ftp_proxy.
no_proxy
Defaults to $no_proxy.
pager
Defaults to $PAGER.
prompt
Defaults to $FTPPROMPT.
rprompt
Defaults to $FTPRPROMPT.
site arg1 arg2 ...
Take the supplied arguments and send them verbatim as a SITE command to the remote FTP server.
size filename
Return the size of the specified file on the remote machine.
sndbuf size
Set the size of the socket send buffer. This option isn't supported by the tiny stack (npm-ttcpip.so).
status
Show the current status of ftp.
struct [structname]
Set the file transfer structure to structname. By default, the stream structure is used.
sunique
Toggle the storing of files on the remote machine under unique filenames (default is off). The remote FTP server must support the FTP-protocol STOU command for successful completion.
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.
throttle
A synonym for rate.
trace
Toggle packet tracing (default is off).
type [typename]
Set the file transfer type to typename. If you omit typename, the current type is printed. The default type is network ASCII. See "File transfer parameters" for the list of valid typenames.
umask [newmask]
Set the default umask on the remote server to newmask. If you omit newmask, the current umask is printed.
unset option
Unset options. See set for more information.
usage command
Print the usage message for command.
user username [password] [account]
Identify yourself to the remote FTP server. If you:
  • omit the password but the server requires it, ftp prompts you for it (after disabling local echo)
  • don't specify an account but the server requires it, you're prompted for it.
  • specify an account, an account command is relayed to the remote server after the login sequence is completed. Unless ftp is invoked with autologin disabled, this process is done automatically on initial connection to the FTP server.
verbose
Toggle verbose mode (default is on). If verbose mode is on, you see all responses from the FTP server. When a file transfer completes, you also see file statistics regarding the efficiency of the transfer.
xferbuf size
Set the size of the socket send and receive buffers. This option isn't supported by the tiny stack (npm-ttcpip.so).
? [command]
A synonym for help.

Auto-fetching files

In addition to standard commands, ftp supports an auto-fetch feature. To enable auto-fetch, simply pass the list of hostnames/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's stored locally with the name basename (see basename 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 using HTTP via the proxy defined in set ftp_proxy. If set ftp_proxy isn't defined, and user is specified, 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 takes place as ASCII or binary (respectively). The default transfer type is binary.

file:///path
A local URL, copied from /path.

If a classic format or a FTP URL format has a trailing /, then ftp connects to the site and cd to the directory specified as the path, and leave the user in interactive mode ready for further input.

If -R is specified, all auto-fetches that don't go via the FTP proxies are restarted. This is implemented with reget instead of get.

If WWW or proxy-WWW authentication is required, you're prompted to enter a username and password.

When specifying IPv6 numeric addresses in a URL, you need to surround the address in square brackets because colons are used in IPv6 numeric address, and as separators for port numbers. For example:

ftp://[::1]:21/

Aborting a file transfer

You abort a file transfer with 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 by 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 doesn't support the ABOR command, an ftp> prompt doesn't appear until the remote server has completed sending the requested file.


Note:

If the terminal interrupt key sequence is used while ftp is waiting for a reply from the remote server for the ABOR processing, then the connection is closed. This is different from the traditional behavior (which ignores the terminal interrupt during this phase), but is considered more useful.


How filenames are processed

When specified as an argument to an ftp command, a filename is processed according to the following rules:

  1. If the filename is a dash (-), stdin (for reading) or stdout (for writing) is used.
  2. If the first character of the filename is |, the remainder of the argument is interpreted as a shell command. The ftp command then forks a shell, using popen() with the argument supplied, and reads from stdout or writes to stdin. If the shell command includes spaces, the argument must be quoted, like this:
    "ls -lt"
            

    A particularly useful example of this mechanism is dir | more.

  3. Failing the above checks, if "globbing" is enabled, local filenames are expanded according to the rules used in sh (as opposed to 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 filenames, 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 filenames, the remote filename is the local filename, which may be altered by an 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 lists many parameters that may affect a file transfer. The type may be one of:

The ftp utility supports the ASCII and image types of file transfer, plus local byte-size 8 for tenex-mode transfers; but it supports only the default values for the remaining file transfer parameters: mode, format, and structure.

The .netrc file

The .netrc file, which resides in your home directory, contains login and initialization information used by ftp's autologin facility. The following tokens are recognized; you can separate them by spaces, tabs, or newline characters:

machine name
Identify a remote machine name. The autologin process searches the .netrc file for a machine token that matches the remote machine specified on the ftp command line or in an open command argument. Once a match is made, the subsequent .netrc tokens are processed, stopping when the end of file is reached or when another machine or a default 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 be after all machine tokens. This is normally used as:
default login anonymous password user@site

thereby giving you automatic anonymous ftp login to machines not specified in .netrc.

You can override this by using the -n option to disable autologin.

login name
Identify a user on the remote machine. If this token is present, the autologin process initiates a login using the specified name.
password string
Supply a password. If this token is present, the autologin process supplies the specified string if the remote server requires a password as part of the login process. Note that if this token is present in the .netrc file for any user other than anonymous, ftp aborts the autologin process if the .netrc is readable by anyone besides the user.
account string
Supply an additional account password. If this token is present, the autologin process supplies the specified string if the remote server requires an additional account password; if the remote server doesn't require an additional password, the autologin process initiates an ACCT command.
macdef name
Define a macro. This token functions like the ftp macdef command. A macro is defined with the specified name; its contents 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's automatically executed as the last step in the autologin process.

Command line prompt

By default, ftp displays a command line prompt of ftp> to the user. This can be changed with the set prompt command.

A prompt can be displayed on the right side of the screen (after the command input) with the set rprompt command.

The following formatting sequences are replaced by the given information:

This format sequence: Is replaced by:
%/ Current remote working directory.
%c[[0]n], %.[[0]n] Trailing component of the current remote working directory, or n trailing components if n is specified. If n begins with 0, the number of skipped components precede the trailing component(s) in the format "/skippedtrailing" (for %c) or ...trailing (for %.).
%M Remote hostname.
%m Remote hostname, up to the first ..
%n Remote username.
%% A single %.

Files:

The ftp utility requires the libsocket.so shared object.

Environment variables:

FTPANONPASS
Password to send in an anonymous FTP transfer (default is whoami@).
FTPMODE
Overrides the default operation mode. Support values are:
  • active -- active-mode FTP only
  • auto -- automatic determination of passive or active (the default)
  • gate -- gate-ftp mode
  • passive -- passive-mode FTP only
FTPPROMPT
Command line prompt to use (defaults is: ftp>). See the "command line prompt" section for more information.
FTPRPROMPT
Command line right side prompt to use (default is no prompt, i.e. ""). See the "command line prompt" section for more information.
ftp_proxy
URL of the FTP proxy to use when making FTP URL requests (the standard FTP protocol if not defined).
FTPSERVER
Host to use as gate-ftp server when gate is enabled.
FTPSERVERPORT
Port to use when connecting to gate-ftp server when gate is enabled. Default is the port returned by a getservbyname() lookup of ftpgate/tcp.
HOME
Default location of a .netrc file, if one exists.
no_proxy
A space or comma separated list of hosts (or domains) for which proxying isn't to be used. Each entry may have an optional trailing ":port" which restricts the matching to connections to that port.
PAGER
Used by various commands to display files. Defaults to more if empty or not set.
SHELL
Default shell.

Caveats:

Correct execution of many commands depends on 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.

The ftp utility assumes that all IPv4 mapped addresses (and IPv6 addresses in the form of ::ffff:10.1.1.1) indicate IPv4 destination which can be handled by AF_INET sockets. However, in certain IPv6 network configuration, the assumption isn't true. In such an environment, IPv4 mapped address must be passed to AF_INET6 sockets directly. For example, if your site uses SIIT translator for IPv6-to-IPv4 translation, ftp is unable to support your configuration.

Earlier versions (before QNX Neutrino) of ftp were unable to access anything other than regular files. This is no longer the case.

See also:

ftpd, /etc/services, tftp

getservbyname() in the Library Reference

RFC 959, RFC 1123, RFC 1738, RFC 2068, RFC 2428, and RFC 2732.


[Previous] [Contents] [Index] [Next]