@
host]]
host
:
[path]
[
/
]
[[user
@
]]
[
file:///
path]
[user
[
:
password]
@
]
[host
:
port]
/
path
[
/
]
[
;type=
X]
[
ftp://
]
[user
[
:
password]
@
]
[host
:
port]
/
path
[
http://
]
[...]
ftp
-u URL file
[...]
The last five arguments will fetch a file using the FTP or HTTP protocols, or by direct copying, into the current directory. This is ideal for scripts. Refer to AUTO-FETCHING FILES below for more information.
Options may be specified at the command line, or to the command interpreter.
~/.netrc
.
Refer to
THE .netrc FILE
for more information.
.netrc
(see below) 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.
To override the auto-login for auto-fetch transfers, specify the
username (and optionally, password) as appropriate.
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:
EPSV
and
EPRT
commands on all IP, IPv4, and IPv6 connections respectively. First try
EPSV
/
EPRT
,
and then
PASV
/
PORT
.
This is enabled by default.
If an extended command fails then this option will be temporarily
disabled for the duration of the current connection, or until
epsv,
epsv4,
or
epsv6
is executed again.
FEAT
command).
FTPSERVER
environment variable).
If
host
is given,
then gate-ftp mode will be enabled, and the gate-ftp server will be set to
host.
If
port
is also given, that will be used as the port to connect to on the
gate-ftp server.
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 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 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 `$'.
MLSD
.
The format of display can be changed with
`remopts mlst ...'.
MLST
.
The format of display can be changed with
`remopts mlst ...'.
RFC2822
format.
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.
FTPMODE
is set to
`auto'.
If passive mode is turned on (default),
ftp
will send a
PASV
command for all data connections instead of a
PORT
command.
The
PASV
command requests that the remote server open a port for the data 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
RFC1123
,
some do not.)
When prompting is on, the following commands are available at a prompt:
Any other response will answer `yes' to the current file.
PASV
command by the server on the secondary control connection.
direction may be one of:
maximum
can be modified on the fly by
increment
bytes (default: 1024) each time a given signal is received:
SIGUSR1
SIGUSR2
If maximum is not supplied, the current throttle rates are displayed.
Note: rate is not yet implemented for ascii mode transfers.
MLSD
and
MLST
).
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.
$FTPANONPASS
$ftp_proxy
.
$http_proxy
.
$no_proxy
.
$PAGER
.
$FTPPROMPT
.
$FTPRPROMPT
.
SITE
command.
STOU
command for
successful completion.
The remote server will report unique name.
Default value is off.
Command arguments which have embedded spaces may be quoted with quote `"' marks.
Commands which toggle settings can take an explicit on or off argument to force the setting appropriately.
Commands which take a byte count as an argument (e.g., hash, rate, and xferbuf) support an optional suffix on the argument which changes the interpretation of the argument. Supported suffixes are:
b
k
m
g
If
ftp
receives a
SIGINFO
(see the
``status''
argument of
stty(1))
or
SIGQUIT
signal whilst a transfer is in progress, the current transfer rate
statistics will be written to the standard error output, in the
same format as the standard completion message.
The following formats are valid syntax for an auto-fetch element:
@
]
host
:
[path]
[
/
]
``Classic''
FTP
format.
If path contains a glob character and globbing is enabled, (see glob), then the equivalent of `mget path' is performed.
If the directory component of path contains no globbing characters, it is stored locally with the name basename (see basename(1)) of path, in the current directory. Otherwise, the full remote name is used as the local name, relative to the local root directory.
ftp://
[
:
password]
@[user
]
host
:
port[.blm Pp]
/
path
[
/
]
[
;type=
X]
An
FTP
URL, retrieved using the
FTP
protocol if
set ftp_proxy
isn't defined.
Otherwise, transfer the URL using
HTTP
via the proxy defined in
set ftp_proxy.
If
set ftp_proxy
isn't defined and
user
is given, login as
user.
In this case, use
password
if supplied, otherwise prompt the user for one.
If a suffix of `;type=A' or `;type=I' is supplied, then the transfer type will take place as ascii or binary (respectively). The default transfer type is binary.
In order to be compliant with
RFC3986
,
ftp
interprets the
path
part of an
``ftp://''
auto-fetch URL as follows:
/
'
immediately after the
host
:
port[.blm Pp]
is interpreted as a separator before the
path,
and not as part of the
path
itself.
/`.blm Pp
-separated '
list of name components.
For all but the last such component,
ftp
performs the equivalent of a
cd
command.
For the last path component,
ftp
performs the equivalent of a
get
command.
//
'
within the
path,
or from an extra
`
/
'
at the beginning of the
path,
will cause the equivalent of a
cd
command without a directory name.
This is unlikely to be useful.
%
XX'
codes
(per
RFC3986
)
within the path components are decoded, with
XX
representing a character code in hexadecimal.
This decoding takes place after the
path
has been split into components,
but before each component is used in the equivalent of a
cd
or
get
command.
Some often-used codes are
`
%2F
'
(which represents
`
/
')
and
`
%7E
'
(which represents
`
~
').
The above interpretation has the following consequences:
/
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''
http://
[
:
password]
@[user
]
host
:
port[.blm Pp]
/
path
An
HTTP
URL, retrieved using the
HTTP
protocol.
If
set http_proxy
is defined, it is used as a URL to an
HTTP
proxy server.
If
HTTP
authorization is required to retrieve
path,
and
`user'
(and optionally
`password')
is in the URL, use them for the first attempt to authenticate.
file:///
path
A local URL, copied from
/
path
on the local host.
about:
topic
Display information regarding
topic;
no file is retrieved for this auto-fetched element.
Supported values include:
about:ftp
about:version
Unless noted otherwise above, and -o output is not given, the file is stored in the current directory as the basename(1) of path. Note that if a HTTP redirect is received, the fetch is retried using the new target URL supplied by the server, with a corresponding new path. Using an explicit -o output is recommended, to avoid writing to unexpected file names.
If a classic format or an FTP URL format has a trailing `/' or an empty path component, then ftp will connect to the site and cd to the directory given as the path, and leave the user in interactive mode ready for further input. This will not work if set ftp_proxy is being used.
Direct HTTP transfers use HTTP 1.1. Proxied FTP and HTTP transfers use HTTP 1.0.
If -R is given, all auto-fetches that don't go via the FTP or HTTP proxies will be restarted. For FTP, this is implemented by using reget instead of get. For HTTP, this is implemented by using the `Range: bytes=' HTTP/1.1 directive.
If WWW or proxy WWW authentication is required, you will be prompted to enter a username and password to authenticate with.
When specifying IPv6 numeric addresses in a URL, you need to surround the address in square brackets. E.g.: ``ftp://[::1]:21/''. This is because colons are used in IPv6 numeric address as well as being the separator for the port number.
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, the prompt will not appear until the remote server has completed
sending the requested file.
If the terminal interrupt key sequence is used whilst ftp is awaiting a reply from the remote server for the ABOR processing, then the connection will be closed. This is different from the traditional behaviour (which ignores the terminal interrupt during this phase), but is considered more useful.
|
ls -lt
''.
A particularly
useful example of this mechanism is:
``
dir
""
|more
''.
ftp supports only the default values for the remaining file transfer parameters: mode, form, and struct.
.netrc
file contains login and initialization information
used by the auto-login process.
It resides in the user's home directory,
unless overridden with the
-N netrc
option, or specified in the
NETRC
environment variable.
The following tokens are recognized; they may be separated by spaces,
tabs, or new-lines:
.netrc
file for a
machine
token 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
tokens are processed,
stopping when the end of file is reached or another
machine
or a
default
token is encountered.
default
login
anonymous
password
user@site
thereby giving the user an automatic anonymous
FTP
login to
machines not specified in
.netrc
.
This can be overridden
by using the
-n
flag to disable auto-login.
.netrc
file for any user other
than
anonymous,
ftp
will abort the auto-login process if the
.netrc
is readable by
anyone besides the user.
ACCT
command if it does not.
.netrc
line and continue until a blank line (consecutive new-line
characters) is encountered.
Like the other tokens in the
.netrc
file, a
macdef
is applicable only to the
machine
definition preceding it.
A
macdef
entry cannot be used by multiple
machine
definitions; rather, it must be defined following each
machine
it is intended to be used with.
If a macro named
init
is defined, it is automatically executed as the last step in the
auto-login process.
For example,
default
macdef init
epsv4 off
followed by a blank line.
The
editline(3)
library is configured with a
.editrc
file - refer to
editrc(5)
for more information.
An extra key binding is available to ftp to provide context sensitive command and filename completion (including remote file completion). To use this, bind a key to the editline(3) command ftp-complete. By default, this is bound to the TAB key.
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:
%/
%c
[
0[.blm Pp
n],]
%.
[
0[.blm Pp
n]]
The trailing component of the current remote working directory, or
n
trailing components if a digit
n
is given.
If
n
begins with
`0',
the number of skipped components precede the trailing component(s) in
the format
trailing
``
/
<
number
>
''
(for
`%c')
or
``
...
trailing''
(for
`%.').
%M
%m
%n
%%
FTPANONPASS
`whoami`@
''.
FTPMODE
FTPPROMPT
FTPRPROMPT
FTPSERVER
FTPSERVERPORT
)
lookup of
``ftpgate/tcp''.
FTPUSERAGENT
HOME
.netrc
file, if one exists.
NETRC
.netrc
file.
PAGER
SHELL
ftp_proxy
See
http_proxy
for further notes about proxy use.
http_proxy
If
``unsafe''
URL characters are required in the username or password
(for example
`@'
or
`/'),
encode them with
RFC3986
`%
XX'
encoding.
Note that the use of a username and password in
ftp_proxy
and
http_proxy
may be incompatible with other programs that use it
(such as
lynx(1)).
NOTE: this is not used for interactive sessions, only for command-line fetches.
no_proxy
229
Entering
Extended
Passive
Mode
(|||58551|)
then you will need to disable extended passive mode with epsv4 off. See the above section The .netrc File for an example of how to make this automatic.
RFC0959
RFC1123
RFC1635
RFC2389
RFC2428
RFC2616
RFC2822
RFC3659
RFC3986
Various features such as command line editing, context sensitive
command and file completion, dynamic progress bar, automatic
fetching of files and URLs, modification time preservation,
transfer rate throttling, configurable command line prompt,
and other enhancements over the standard
BSD
ftp
were implemented in
NetBSD1.3
and later releases
by
Luke Mewburn
<lukem@NetBSD.org>.
IPv6 support was added by the WIDE/KAME project (but may not be present in all non-NetBSD versions of this program, depending if the operating system supports IPv6 in a similar manner to KAME).
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.
ftp
assumes that all IPv4 mapped addresses
::ffff:10.1.1.1
(IPv6 addresses with a form like)
indicate IPv4 destinations which can be handled by
AF_INET
sockets.
However, in certain IPv6 network configurations, this assumption is not true.
In such an environment, IPv4 mapped addresses must be passed to
AF_INET6
sockets directly.
For example, if your site uses a SIIT translator for IPv6-to-IPv4 translation,
ftp
is unable to support your configuration.