1.\"- 2.\" Copyright (c) 2000 Dag-Erling Co�dan Sm�rgrav 3.\" All rights reserved. 4.\" Portions Copyright (c) 1999 Massachusetts Institute of Technology; used 5.\" by permission. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer 12.\" in this position and unchanged. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. The name of the author may not be used to endorse or promote products 17.\" derived from this software without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29.\" 30.\" $FreeBSD$ 31.\" 32.Dd March 11, 2003 33.Dt FETCH 1 34.Os 35.Sh NAME 36.Nm fetch 37.Nd retrieve a file by Uniform Resource Locator 38.Sh SYNOPSIS 39.Nm 40.Op Fl 146AFMPRUadlmnpqrsv 41.Op Fl B Ar bytes 42.Op Fl S Ar bytes 43.Op Fl T Ar seconds 44.Op Fl N Ar file 45.Op Fl o Ar file 46.Op Fl w Ar seconds 47.Op Fl h Ar host 48.Op Fl c Ar dir 49.Op Fl f Ar file 50.Op Ar URL ... 51.Sh DESCRIPTION 52The 53.Nm 54utility provides a command-line interface to the 55.Xr fetch 3 56library. 57Its purpose is to retrieve the file(s) pointed to by the URL(s) on the 58command line. 59.Pp 60The following options are available: 61.Bl -tag -width Fl 62.It Fl \&1 63Stop and return exit code 0 at the first successfully retrieved file. 64.It Fl 4 65Forces 66.Nm 67to use IPv4 addresses only. 68.It Fl 6 69Forces 70.Nm 71to use IPv6 addresses only. 72.It Fl A 73Do not automatically follow ``temporary'' (302) redirects. 74Some broken Web sites will return a redirect instead of a not-found 75error when the requested object does not exist. 76.It Fl a 77Automatically retry the transfer upon soft failures. 78.It Fl B Ar bytes 79Specify the read buffer size in bytes. 80The default is 4096 bytes. 81Attempts to set a buffer size lower than this will be silently 82ignored. 83The number of reads actually performed is reported at verbosity level 84two or higher (see the 85.Fl v 86flag). 87.It Fl c Ar dir 88The file to retrieve is in directory 89.Ar dir 90on the remote host. 91This option is deprecated and is provided for backward compatibility 92only. 93.It Fl d 94Use a direct connection even if a proxy is configured. 95.It Fl F 96In combination with the 97.Fl r 98flag, forces a restart even if the local and remote files have 99different modification times. 100Implies 101.Fl R . 102.It Fl f Ar file 103The file to retrieve is named 104.Ar file 105on the remote host. 106This option is deprecated and is provided for backward compatibility 107only. 108.It Fl h Ar host 109The file to retrieve is located on the host 110.Ar host . 111This option is deprecated and is provided for backward compatibility 112only. 113.It Fl l 114If the target is a file-scheme URL, make a symbolic link to the target 115rather than trying to copy it. 116.It Fl M 117.It Fl m 118Mirror mode: if the file already exists locally and has the same size 119and modification time as the remote file, it will not be fetched. 120Note that the 121.Fl m 122and 123.Fl r 124flags are mutually exclusive. 125.It Fl N Ar file 126Use 127.Ar file 128instead of 129.Pa ~/.netrc 130to look up login names and passwords for FTP sites. 131See 132.Xr ftp 1 133for a description of the file format. 134This feature is experimental. 135.It Fl n 136Don't preserve the modification time of the transferred file. 137.It Fl o Ar file 138Set the output file name to 139.Ar file . 140By default, a ``pathname'' is extracted from the specified URI, and 141its basename is used as the name of the output file. 142A 143.Ar file 144argument of 145.Sq Li \&- 146indicates that results are to be directed to the standard output. 147.It Fl P 148.It Fl p 149Use passive FTP. 150This is useful if you are behind a firewall which blocks incoming 151connections. 152Try this flag if 153.Nm 154seems to hang when retrieving FTP URLs. 155.It Fl q 156Quiet mode. 157.It Fl R 158The output files are precious, and should not be deleted under any 159circumstances, even if the transfer failed or was incomplete. 160.It Fl r 161Restart a previously interrupted transfer. 162Note that the 163.Fl m 164and 165.Fl r 166flags are mutually exclusive. 167.It Fl S Ar bytes 168Require the file size reported by the server to match the specified 169value. 170If it does not, a message is printed and the file is not fetched. 171If the server does not support reporting file sizes, this option is 172ignored and the file is fetched unconditionally. 173.It Fl s 174Print the size in bytes of each requested file, without fetching it. 175.It Fl T Ar seconds 176Set timeout value to 177.Ar seconds . 178Overrides the environment variables 179.Ev FTP_TIMEOUT 180for FTP transfers or 181.Ev HTTP_TIMEOUT 182for HTTP transfers if set. 183.It Fl U 184When using passive FTP, allocate the port for the data connection from 185the low (default) port range. 186See 187.Xr ip 4 188for details on how to specify which port range this corresponds to. 189.It Fl v 190Increase verbosity level. 191.It Fl w Ar seconds 192When the 193.Fl a 194flag is specified, wait this many seconds between successive retries. 195.El 196.Pp 197If 198.Nm 199receives a 200.Dv SIGINFO 201signal (see the 202.Cm status 203argument for 204.Xr stty 1 ) , 205the current transfer rate statistics will be written to the 206standard error output, in the same format as the standard completion 207message. 208.Sh DIAGNOSTICS 209The 210.Nm 211command returns zero on success, or one on failure. 212If multiple URLs are listed on the command line, 213.Nm 214will attempt to retrieve them each of them in turn, and return zero 215only if they were all successfully retrieved. 216.Sh ENVIRONMENT 217.Bl -tag -width HTTP_TIMEOUT 218.It Ev FTP_TIMEOUT 219maximum time, in seconds, to wait before aborting an 220.Tn FTP 221connection. 222.It Ev HTTP_TIMEOUT 223maximum time, in seconds, to wait before aborting an 224.Tn HTTP 225connection. 226.El 227.Pp 228All environment variables mentioned in the documentation for the 229.Xr fetch 3 230library are supported. 231.Sh SEE ALSO 232.Xr fetch 3 233.Sh HISTORY 234The 235.Nm 236command appeared in 237.Fx 2.1.5 . 238This implementation first appeared in 239.Fx 4.1 . 240.Sh AUTHORS 241.An -nosplit 242The original implementation of 243.Nm 244was done by 245.An Jean-Marc Zucconi . 246It was extensively re-worked for 247.Fx 2.2 248by 249.An Garrett Wollman , 250and later completely rewritten to use the 251.Xr fetch 3 252library by 253.An Dag-Erling Sm\(/orgrav . 254.Sh NOTES 255The 256.Fl b 257and 258.Fl t 259options are no longer supported and will generate warnings. 260They were workarounds for bugs in other OSes which this implementation 261does not trigger. 262.Pp 263One cannot both use the 264.Fl h , 265.Fl c 266and 267.Fl f 268options and specify URLs on the command line. 269