fetch.1 revision 124963
-
Copyright (c) 2000 Dag-Erling Co�dan Sm�rgrav
All rights reserved.
Portions Copyright (c) 1999 Massachusetts Institute of Technology; used
by permission.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer
in this position and unchanged.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$FreeBSD: head/usr.bin/fetch/fetch.1 124963 2004-01-25 11:39:42Z des $

.Dd March 11, 2003 .Dt FETCH 1 .Os .Sh NAME .Nm fetch .Nd retrieve a file by Uniform Resource Locator .Sh SYNOPSIS .Nm .Op Fl 146AFMPRUadlmnpqrsv .Op Fl B Ar bytes .Op Fl S Ar bytes .Op Fl T Ar seconds .Op Fl N Ar file .Op Fl o Ar file .Op Fl w Ar seconds .Op Fl h Ar host .Op Fl c Ar dir .Op Fl f Ar file .Op Ar URL ... .Sh DESCRIPTION The .Nm utility provides a command-line interface to the .Xr fetch 3 library. Its purpose is to retrieve the file(s) pointed to by the URL(s) on the command line.

p The following options are available: l -tag -width Fl t Fl 1 Stop and return exit code 0 at the first successfully retrieved file. t Fl 4 Forces .Nm to use IPv4 addresses only. t Fl 6 Forces .Nm to use IPv6 addresses only. t Fl A Do not automatically follow ``temporary'' (302) redirects. Some broken Web sites will return a redirect instead of a not-found error when the requested object does not exist. t Fl a Automatically retry the transfer upon soft failures. t Fl B Ar bytes Specify the read buffer size in bytes. The default is 4096 bytes. Attempts to set a buffer size lower than this will be silently ignored. The number of reads actually performed is reported at verbosity level two or higher (see the .Fl v flag). t Fl c Ar dir The file to retrieve is in directory .Ar dir on the remote host. This option is deprecated and is provided for backward compatibility only. t Fl d Use a direct connection even if a proxy is configured. t Fl F In combination with the .Fl r flag, forces a restart even if the local and remote files have different modification times. Implies .Fl R . t Fl f Ar file The file to retrieve is named .Ar file on the remote host. This option is deprecated and is provided for backward compatibility only. t Fl h Ar host The file to retrieve is located on the host .Ar host . This option is deprecated and is provided for backward compatibility only. t Fl l If the target is a file-scheme URL, make a symbolic link to the target rather than trying to copy it. t Fl M t Fl m Mirror mode: if the file already exists locally and has the same size and modification time as the remote file, it will not be fetched. Note that the .Fl m and .Fl r flags are mutually exclusive. t Fl N Ar file Use .Ar file instead of

a ~/.netrc to look up login names and passwords for FTP sites. See .Xr ftp 1 for a description of the file format. This feature is experimental. t Fl n Don't preserve the modification time of the transferred file. t 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. t Fl P t Fl p Use passive FTP. This is useful if you are behind a firewall which blocks incoming connections. Try this flag if .Nm seems to hang when retrieving FTP URLs. t Fl q Quiet mode. t Fl R The output files are precious, and should not be deleted under any circumstances, even if the transfer failed or was incomplete. t Fl r Restart a previously interrupted transfer. Note that the .Fl m and .Fl r flags are mutually exclusive. t Fl S Ar bytes Require the file size reported by the server to match the specified value. If it does not, a message is printed and the file is not fetched. If the server does not support reporting file sizes, this option is ignored and the file is fetched unconditionally. t Fl s Print the size in bytes of each requested file, without fetching it. t Fl T Ar seconds Set timeout value to .Ar seconds . Overrides the environment variables .Ev FTP_TIMEOUT for FTP transfers or .Ev HTTP_TIMEOUT for HTTP transfers if set. t Fl U When using passive FTP, allocate the port for the data connection from the low (default) port range. See .Xr ip 4 for details on how to specify which port range this corresponds to. t Fl v Increase verbosity level. t Fl w Ar seconds When the .Fl a flag is specified, wait this many seconds between successive retries. .El

p If .Nm receives a .Dv SIGINFO signal (see the .Cm status argument for .Xr stty 1 ) , the current transfer rate statistics will be written to the standard error output, in the same format as the standard completion message. .Sh DIAGNOSTICS The .Nm command returns zero on success, or one on failure. If multiple URLs are listed on the command line, .Nm will attempt to retrieve them each of them in turn, and return zero only if they were all successfully retrieved. .Sh ENVIRONMENT l -tag -width ".Ev FETCH_BIND_ADDRESS" t Ev FETCH_BIND_ADDRESS Specifies a hostname or IP address to which sockets used for outgoing connections will be bound. t Ev FTP_LOGIN Default FTP login if none was provided in the URL. t Ev FTP_PASSIVE_MODE If set to anything but .Ql no , forces the FTP code to use passive mode. t Ev FTP_PASSWORD Default FTP password if the remote server requests one and none was provided in the URL. t Ev FTP_PROXY URL of the proxy to use for FTP requests. The document part is ignored. FTP and HTTP proxies are supported; if no scheme is specified, FTP is assumed. If the proxy is an FTP proxy, .Nm fetch will send .Ql user@host as user name to the proxy, where .Ql user is the real user name, and .Ql host is the name of the FTP server.

p If this variable is set to an empty string, no proxy will be used for FTP requests, even if the .Ev HTTP_PROXY variable is set. t Ev ftp_proxy Same as .Ev FTP_PROXY , for compatibility. t Ev HTTP_AUTH Specifies HTTP authorization parameters as a colon-separated list of items. The first and second item are the authorization scheme and realm respectively; further items are scheme-dependent. Currently, only basic authorization is supported.

p Basic authorization requires two parameters: the user name and password, in that order.

p This variable is only used if the server requires authorization and no user name or password was specified in the URL. t Ev HTTP_PROXY URL of the proxy to use for HTTP requests. The document part is ignored. Only HTTP proxies are supported for HTTP requests. If no port number is specified, the default is 3128.

p Note that this proxy will also be used for FTP documents, unless the .Ev FTP_PROXY variable is set. t Ev http_proxy Same as .Ev HTTP_PROXY , for compatibility. t Ev HTTP_PROXY_AUTH Specifies authorization parameters for the HTTP proxy in the same format as the .Ev HTTP_AUTH variable.

p This variable is used if and only if connected to an HTTP proxy, and is ignored if a user and/or a password were specified in the proxy URL. t Ev HTTP_REFERER Specifies the referrer URL to use for HTTP requests. If set to .Dq auto , the document URL will be used as referrer URL. t Ev HTTP_USER_AGENT Specifies the User-Agent string to use for HTTP requests. This can be useful when working with HTTP origin or proxy servers that differentiate between user agents. t Ev NETRC Specifies a file to use instead of

a ~/.netrc to look up login names and passwords for FTP sites. See .Xr ftp 1 for a description of the file format. This feature is experimental. .El .Sh EXAMPLES To access a proxy server on

a proxy.example.com port 8080, set the .Ev HTTP_PROXY environment variable in a manner similar to this:

p .Dl HTTP_PROXY=<A HREF="http://proxy.example.com:8080">http://proxy.example.com:8080</A>

p If the proxy server requires authentication, there are two options available for passing the authentication data. The first method is by using the proxy URL:

p .Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080

p The second method is by using the .Ev HTTP_PROXY_AUTH environment variable: d -literal -offset indent HTTP_PROXY=<A HREF="http://proxy.example.com:8080">http://proxy.example.com:8080</A> HTTP_PROXY_AUTH=basic:*:<user>:<pwd> .Ed .Sh SEE ALSO .Xr fetch 3 .Sh HISTORY The .Nm command appeared in .Fx 2.1.5 . This implementation first appeared in .Fx 4.1 . .Sh AUTHORS .An -nosplit The original implementation of .Nm was done by .An Jean-Marc Zucconi Aq jmz@FreeBSD.org . It was extensively re-worked for .Fx 2.2 by .An Garrett Wollman Aq wollman@FreeBSD.org , and later completely rewritten to use the .Xr fetch 3 library by .An Dag-Erling Co\(:idan Sm\(/orgrav Aq des@FreeBSD.org . .Sh NOTES The .Fl b and .Fl t options are no longer supported and will generate warnings. They were workarounds for bugs in other OSes which this implementation does not trigger.

p One cannot both use the .Fl h , .Fl c and .Fl f options and specify URLs on the command line.