1998-05-09 20:50:37 +00:00
|
|
|
.\" $Id: fetch.1,v 1.21 1998/05/09 07:33:09 fenner Exp $
|
1996-07-05 01:03:20 +00:00
|
|
|
.Dd July 2, 1996
|
|
|
|
.Dt FETCH 1
|
1997-02-22 23:43:32 +00:00
|
|
|
.Os FreeBSD 2.2
|
1996-07-05 01:03:20 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fetch
|
|
|
|
.Nd retrieve a file by Uniform Resource Locator
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm fetch
|
1997-07-25 19:35:44 +00:00
|
|
|
.Op Fl MPabmnpqr
|
1996-07-05 01:03:20 +00:00
|
|
|
.Op Fl o Ar file
|
|
|
|
.Ar URL
|
1997-02-05 19:59:18 +00:00
|
|
|
.Op Ar ...
|
1996-07-05 01:03:20 +00:00
|
|
|
.Nm fetch
|
1997-01-30 21:43:44 +00:00
|
|
|
.Op Fl MPRmnpqr
|
1996-07-05 01:03:20 +00:00
|
|
|
.Op Fl o Ar file
|
|
|
|
.Op Fl c Ar dir
|
|
|
|
.Fl f Ar file
|
|
|
|
.Fl h Ar host
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm fetch
|
|
|
|
allows a user to transfer files from a remote network site using
|
|
|
|
either the
|
1997-02-05 19:59:18 +00:00
|
|
|
.Tn FTP
|
1996-07-05 01:03:20 +00:00
|
|
|
or the
|
1997-02-05 19:59:18 +00:00
|
|
|
.Tn HTTP
|
1996-07-05 01:03:20 +00:00
|
|
|
protocol. In the first form of the command, the
|
|
|
|
.Ar URL
|
|
|
|
may be of the form
|
1997-01-30 21:43:44 +00:00
|
|
|
.Li http://site.domain/path/to/the/file
|
1996-07-05 01:03:20 +00:00
|
|
|
or
|
1998-05-09 07:33:09 +00:00
|
|
|
.Li ftp://site.domain/path/to/the/file .
|
1997-01-30 21:43:44 +00:00
|
|
|
To denote a local filename to be copied or linked to (see the
|
1996-08-22 21:30:51 +00:00
|
|
|
.Fl l
|
1997-01-30 21:43:44 +00:00
|
|
|
flag below), the
|
1996-08-22 21:30:51 +00:00
|
|
|
.Em file:/path/to/the/file
|
1998-05-09 07:33:09 +00:00
|
|
|
URL form is used. See URL SYNTAX, below.
|
1997-01-30 21:43:44 +00:00
|
|
|
.Pp
|
1996-07-05 01:03:20 +00:00
|
|
|
The second form of the command can be used to get a file using the
|
1997-01-30 21:43:44 +00:00
|
|
|
.Tn FTP
|
1996-07-05 01:03:20 +00:00
|
|
|
protocol, specifying the file name and the remote host with the
|
|
|
|
.Fl h
|
|
|
|
and the
|
|
|
|
.Fl f
|
|
|
|
flags.
|
|
|
|
.Pp
|
|
|
|
The following options are available:
|
1997-02-05 19:59:18 +00:00
|
|
|
.Bl -tag -width Fl
|
1997-01-31 19:55:51 +00:00
|
|
|
.It Fl a
|
|
|
|
Automatically retry the transfer upon soft failures.
|
1997-07-25 19:35:44 +00:00
|
|
|
.It Fl b
|
|
|
|
Work around a bug in some
|
|
|
|
.Tn HTTP
|
|
|
|
servers which fail to correctly implement the
|
|
|
|
.Tn TCP
|
|
|
|
protocol.
|
1996-07-05 01:03:20 +00:00
|
|
|
.It Fl c Ar dir
|
1997-01-30 21:43:44 +00:00
|
|
|
The file to retrieve is in directory
|
1996-07-05 01:03:20 +00:00
|
|
|
.Ar dir
|
1997-01-30 21:43:44 +00:00
|
|
|
on the remote host.
|
1996-07-05 01:03:20 +00:00
|
|
|
.It Fl f Ar file
|
1997-01-30 21:43:44 +00:00
|
|
|
The file to retrieve is named
|
1996-07-05 01:03:20 +00:00
|
|
|
.Ar file
|
|
|
|
on the remote host.
|
|
|
|
.It Fl h Ar host
|
1997-01-30 21:43:44 +00:00
|
|
|
The file to retrieve is located on the host
|
|
|
|
.Ar host .
|
1996-08-22 21:30:51 +00:00
|
|
|
.It Fl l
|
|
|
|
If target is a
|
|
|
|
.Ar file:/
|
|
|
|
style of URL, make a link to the target rather than trying
|
|
|
|
to copy it.
|
1997-01-30 21:43:44 +00:00
|
|
|
.It Fl M
|
|
|
|
.It Fl m
|
|
|
|
Mirror mode: Set the modification time of the file so that it is
|
|
|
|
identical to the modification time of the file at the remote host.
|
|
|
|
If the file already exists on the local host and is identical (as
|
|
|
|
gauged by size and modification time), no transfer is done.
|
|
|
|
.It Fl n
|
|
|
|
Don't preserve the modtime of the transfered file, use the current time.
|
|
|
|
.It Fl o Ar file
|
|
|
|
Set the output file name to
|
|
|
|
.Ar file .
|
|
|
|
By default, a ``pathname'' is extracted from the specified URI, and
|
|
|
|
its basename is used as the name of the output file. A
|
|
|
|
.Ar file
|
|
|
|
argument of
|
|
|
|
.Sq Li \&-
|
|
|
|
indicates that results are to be directed to the standard output.
|
|
|
|
.It Fl P
|
|
|
|
.It Fl p
|
|
|
|
Use the passive mode of the
|
|
|
|
.Tn FTP
|
|
|
|
protocol. This is useful for crossing certain sorts of firewalls.
|
|
|
|
.It Fl q
|
|
|
|
Quiet mode. Do not report transfer progress on the terminal.
|
|
|
|
.It Fl R
|
|
|
|
The filenames specified are ``precious'', and should not be deleted
|
|
|
|
under any circumstances, even if the transfer failed or was incomplete.
|
|
|
|
.It Fl r
|
|
|
|
Restart a previously interrupted transfer.
|
1997-08-05 20:18:39 +00:00
|
|
|
.It Fl t
|
1998-05-09 20:50:37 +00:00
|
|
|
Work around a different set of buggy
|
|
|
|
.Tn TCP
|
|
|
|
implementations.
|
1996-08-22 21:30:51 +00:00
|
|
|
.It Fl T Ar seconds
|
|
|
|
Set timeout value to
|
|
|
|
.Ar seconds.
|
1996-09-19 18:07:24 +00:00
|
|
|
Overrides the environment variables
|
1996-08-22 21:30:51 +00:00
|
|
|
.Ev FTP_TIMEOUT
|
1996-09-19 18:07:24 +00:00
|
|
|
for ftp transfers or
|
|
|
|
.Ev HTTP_TIMEOUT
|
|
|
|
for http transfers if set.
|
1996-08-31 22:03:05 +00:00
|
|
|
.It Fl v
|
1997-01-30 21:43:44 +00:00
|
|
|
Increase verbosity. More
|
|
|
|
.Fl v Ns \&'s
|
|
|
|
result in more information.
|
1996-07-05 01:03:20 +00:00
|
|
|
.El
|
1997-01-30 21:43:44 +00:00
|
|
|
.Pp
|
|
|
|
Many options are also controlled solely by the environment (this is a
|
|
|
|
bug).
|
1998-05-09 07:33:09 +00:00
|
|
|
.Sh URL SYNTAX
|
|
|
|
.Nm
|
|
|
|
accepts
|
|
|
|
.Tn http
|
|
|
|
and
|
|
|
|
.Tn ftp
|
|
|
|
URL's, as described in RFC1738. For
|
|
|
|
.Tn ftp
|
|
|
|
URL's, a username and password may be specified, using the syntax
|
|
|
|
.Li ftp://user:password@host/.
|
|
|
|
If the path is to be absolute, as opposed to relative to the user's
|
|
|
|
home directory, it must start with %2F, as in
|
|
|
|
.Li ftp://root:mypass@localhost/%2Fetc/passwd .
|
1997-01-30 21:43:44 +00:00
|
|
|
.Sh PROXY SERVERS
|
|
|
|
Many sites use application gateways (``proxy servers'') in their
|
|
|
|
firewalls in order to allow communication across the firewall using a
|
|
|
|
trusted protocol. The
|
|
|
|
.Nm fetch
|
|
|
|
program can use both the
|
|
|
|
.Tn FTP
|
|
|
|
and the
|
|
|
|
.Tn HTTP
|
|
|
|
protocol with a proxy server.
|
|
|
|
.Tn FTP
|
|
|
|
proxy servers can only relay
|
|
|
|
.Tn FTP
|
|
|
|
requests;
|
|
|
|
.Tn HTTP
|
|
|
|
proxy servers can relay both
|
|
|
|
.Tn FTP
|
|
|
|
and
|
|
|
|
.Tn HTTP
|
|
|
|
requests.
|
|
|
|
A proxy server can be configured by defining an environment variable
|
|
|
|
named
|
|
|
|
.Dq Va PROTO Ns Ev _PROXY ,
|
|
|
|
where
|
|
|
|
.Va PROTO
|
|
|
|
is the name of the protocol in upper case. The value of the
|
|
|
|
environment variable specifies a hostname, optionally followed by a
|
|
|
|
colon and a port number.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Tn FTP
|
1997-03-05 18:57:16 +00:00
|
|
|
proxy client passes the remote username, host and port as the
|
1997-01-30 21:43:44 +00:00
|
|
|
.Tn FTP
|
1997-03-05 18:57:16 +00:00
|
|
|
session's username, in the form
|
|
|
|
.Do Va remoteuser Ns Li \&@ Ns Va remotehost
|
|
|
|
.Op Li \^@ Ns Va port
|
|
|
|
.Dc .
|
1997-01-30 21:43:44 +00:00
|
|
|
The
|
|
|
|
.Tn HTTP
|
|
|
|
proxy client simply passes the originally-requested URI to the remote
|
|
|
|
server in an
|
|
|
|
.Tn HTTP
|
|
|
|
.Dq Li GET
|
|
|
|
request. HTTP proxy authentication is not yet implemented.
|
1997-02-05 19:59:18 +00:00
|
|
|
.Sh HTTP AUTHENTICATION
|
|
|
|
The
|
|
|
|
.Tn HTTP
|
|
|
|
protocol includes support for various methods of authentication.
|
|
|
|
Currently, the
|
|
|
|
.Dq basic
|
|
|
|
method, which provides no security from packet-sniffing or
|
|
|
|
man-in-the-middle attacks, is the only method supported in
|
|
|
|
.Nm fetch .
|
|
|
|
Authentication is enabled by the
|
|
|
|
.Ev HTTP_AUTH
|
|
|
|
and
|
|
|
|
.Ev HTTP_PROXY_AUTH
|
|
|
|
environment variables. Both variables have the same format, which
|
|
|
|
consists of space-separated list of parameter settings, where each
|
|
|
|
setting consists of a colon-separated list of parameters. The first
|
|
|
|
two parameters are always the (case-insensitive) authentication scheme
|
|
|
|
name and the realm in which authentication is to be performed. If the
|
|
|
|
realm is specified as
|
|
|
|
.Sq Li \&* ,
|
|
|
|
then it will match all realms not specified otherwise.
|
|
|
|
.Pp
|
1998-05-09 20:50:37 +00:00
|
|
|
The
|
1997-02-05 19:59:18 +00:00
|
|
|
.Li basic
|
|
|
|
authentication scheme uses two additional optional parameters; the
|
|
|
|
first is a user name, and the second is the password associated with
|
|
|
|
it. If either the password or both parameters are not specified in
|
|
|
|
the environment, and the standard input of
|
|
|
|
.Nm
|
|
|
|
is connected to a terminal, then
|
|
|
|
.Nm
|
|
|
|
will prompt the user to enter the missing parameters. Thus, if the
|
|
|
|
user is known as
|
|
|
|
.Dq Li jane
|
|
|
|
in the
|
|
|
|
.Dq Li WallyWorld
|
|
|
|
realm, and has a password of
|
|
|
|
.Dq Li QghiLx79
|
|
|
|
there, then she might set her
|
|
|
|
.Ev HTTP_AUTH
|
|
|
|
variable to:
|
|
|
|
.Bl -enum -offset indent
|
|
|
|
.It
|
|
|
|
.Dq Li basic:WallyWorld:jane:QghiLx79
|
|
|
|
.It
|
|
|
|
.Dq Li basic:WallyWorld:jane ,
|
|
|
|
or
|
|
|
|
.It
|
|
|
|
.Dq Li basic:WallyWorld
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
and
|
|
|
|
.Nm
|
|
|
|
will prompt for the missing information if it is required. She might
|
|
|
|
also specify a realm of
|
|
|
|
.Dq Li \&*
|
|
|
|
instead of
|
|
|
|
.Dq Li WallyWorld
|
|
|
|
to indicate that the parameters can be applied to any realm. (This is
|
|
|
|
most commonly used in a construction such as
|
|
|
|
.Dq Li basic:* ,
|
|
|
|
which indicates to
|
|
|
|
.Nm
|
|
|
|
that it may offer to do
|
|
|
|
.Li basic
|
|
|
|
authentication for any realm.
|
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command returns zero on success, or a non-zero value from
|
|
|
|
.Aq Pa sysexits.h
|
|
|
|
on failure. If multiple URIs are given for retrieval,
|
|
|
|
.Nm
|
|
|
|
will attempt all of them and return zero only if all succeeded
|
|
|
|
(otherwise it will return the error from the last failure).
|
1996-07-05 01:03:20 +00:00
|
|
|
.Sh ENVIRONMENT
|
1997-01-30 21:43:44 +00:00
|
|
|
.Bl -tag -width FTP_PASSIVE_MODE -offset indent
|
|
|
|
.It Ev FTP_TIMEOUT
|
|
|
|
maximum time, in seconds, to wait before aborting an
|
|
|
|
.Tn FTP
|
|
|
|
connection.
|
|
|
|
.It Ev FTP_LOGIN
|
|
|
|
the login name used for
|
|
|
|
.Tn FTP
|
|
|
|
transfers (default
|
|
|
|
.Dq Li anonymous )
|
1997-02-05 19:59:18 +00:00
|
|
|
.It Ev FTP_PASSIVE_MODE
|
|
|
|
force the use of passive mode FTP
|
1997-01-30 21:43:44 +00:00
|
|
|
.It Ev FTP_PASSWORD
|
|
|
|
the password used for
|
|
|
|
.Tn FTP
|
|
|
|
transfers (default
|
|
|
|
.Dq Va yourname Ns Li \&@ Ns Va yourhost )
|
|
|
|
.It Ev FTP_PROXY
|
1997-03-05 18:57:16 +00:00
|
|
|
the address (in the form
|
|
|
|
.Do Va hostname Ns
|
|
|
|
.Op Li : Ns Va port
|
|
|
|
.Dc )
|
|
|
|
of a proxy server which understands
|
1997-01-30 21:43:44 +00:00
|
|
|
.Tn FTP
|
1997-02-05 19:59:18 +00:00
|
|
|
.It Ev HTTP_AUTH
|
|
|
|
defines authentication parameters for
|
|
|
|
.Tn HTTP
|
|
|
|
.It Ev HTTP_PROXY
|
1997-03-05 18:57:16 +00:00
|
|
|
the address (in the form
|
|
|
|
.Do Va hostname Ns
|
|
|
|
.Op Li : Ns Va port
|
|
|
|
.Dc )
|
|
|
|
of a proxy server which understands
|
1997-02-05 19:59:18 +00:00
|
|
|
.Tn HTTP
|
|
|
|
.It Ev HTTP_PROXY_AUTH
|
|
|
|
defines authentication parameters for
|
|
|
|
.Tn HTTP
|
|
|
|
proxy servers
|
|
|
|
.It Ev HTTP_TIMEOUT
|
|
|
|
maximum time, in seconds, to wait before aborting an
|
|
|
|
.Tn HTTP
|
|
|
|
connection.
|
1996-07-05 01:03:20 +00:00
|
|
|
.Sh SEE ALSO
|
1997-01-15 23:25:55 +00:00
|
|
|
.Xr ftp 1 ,
|
|
|
|
.Xr tftp 1
|
1996-07-05 01:03:20 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm fetch
|
1996-08-23 00:57:08 +00:00
|
|
|
command appeared in
|
|
|
|
.Fx 2.1.5 .
|
1997-01-30 21:43:44 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
The original implementation of
|
|
|
|
.Nm
|
1998-03-23 07:48:45 +00:00
|
|
|
was done by
|
|
|
|
.An Jean-Marc Zucconi .
|
|
|
|
It was extensively re-worked for
|
1997-02-22 23:43:32 +00:00
|
|
|
.Fx 2.2
|
1998-03-23 07:48:45 +00:00
|
|
|
by
|
|
|
|
.An Garrett Wollman .
|
1997-01-31 19:55:51 +00:00
|
|
|
.Sh BUGS
|
|
|
|
There are too many environment variables and command-line options.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl a
|
|
|
|
option is only implemented for certain kinds of
|
|
|
|
.Tn HTTP
|
|
|
|
failures, and no
|
|
|
|
.Tn FTP
|
|
|
|
failures.
|
|
|
|
.Pp
|
1997-02-05 19:59:18 +00:00
|
|
|
Only the
|
|
|
|
.Dq basic
|
|
|
|
authentication mode is implemented for
|
|
|
|
.Tn HTTP .
|
|
|
|
This should be replaced by digest authentication.
|
1997-07-25 19:35:44 +00:00
|
|
|
.Pp
|
1998-05-09 20:50:37 +00:00
|
|
|
Some
|
|
|
|
.Tn TCP
|
|
|
|
implementations (other than
|
|
|
|
.Fx )
|
|
|
|
fail to correctly implement cases where the
|
|
|
|
.Dv SYN
|
|
|
|
and/or
|
|
|
|
.Dv FIN
|
|
|
|
control flags are specified in packets which also contain data.
|
1997-07-25 19:35:44 +00:00
|
|
|
The
|
1998-05-09 20:50:37 +00:00
|
|
|
.Sq Fl t
|
|
|
|
flag works around the latter deficiency and the
|
|
|
|
.Sq Fl b
|
|
|
|
flag works around the former. Since these are errors of the server's
|
|
|
|
.Tn TCP
|
|
|
|
stack, the best we can do is provide these workarounds. Given a correct
|
|
|
|
server, an optimal
|
|
|
|
.Tn HTTP
|
|
|
|
transfer without
|
|
|
|
.Fl t
|
|
|
|
and
|
1997-07-25 19:35:44 +00:00
|
|
|
.Fl b
|
1998-05-09 20:50:37 +00:00
|
|
|
involves a minimum of two round trips (for small replies), one less than
|
|
|
|
other implementations.
|