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 June 28, 2000 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 146AFHMPRadlmnpqrsv 41.Op Fl B Ar bytes 42.Op Fl S Ar bytes 43.Op Fl T Ar seconds 44.Op Fl o Ar file 45.Op Fl w Ar seconds 46.Op Fl h Ar host 47.Op Fl c Ar dir 48.Op Fl f Ar file 49.Op Ar URL ... 50.Sh DESCRIPTION 51.Nm Fetch 52provides a command-line interface to the 53.Xr fetch 3 54library. 55Its purpose is to retrieve the file(s) pointed to by the URL(s) on the 56command line. 57.Pp 58The following options are available: 59.Bl -tag -width Fl 60.It Fl \&1 61Stop and return exit code 0 at the first successfully retrieved file. 62.It Fl 4 63Forces 64.Nm 65to use IPv4 addresses only. 66.It Fl 6 67Forces 68.Nm 69to use IPv6 addresses only. 70.It Fl A 71Do not automatically follow ``temporary'' (302) redirects. 72Some broken Web sites will return a redirect instead of a not-found 73error when the requested object does not exist. 74.It Fl a 75Automatically retry the transfer upon soft failures. 76.It Fl B Ar bytes 77Specify the read buffer size in bytes. 78The default is 4096 bytes. 79Attempts to set a buffer size lower than this will be silently 80ignored. 81The number of reads actually performed is reported at verbosity level 82two or higher (see the 83.Fl v 84flag). 85.It Fl c Ar dir 86The file to retrieve is in directory 87.Ar dir 88on the remote host. 89This option is deprecated and is provided for backward compatibility 90only. 91.It Fl d 92Use a direct connection even if a proxy is configured. 93.It Fl F 94In combination with the 95.Fl r 96flag, forces a restart even if the local and remote files have 97different modification times. 98.It Fl f Ar file 99The file to retrieve is named 100.Ar file 101on the remote host. 102This option is deprecated and is provided for backward compatibility 103only. 104.It Fl H 105When using passive FTP, allocate a high port for the data connection. 106See 107.Xr ip 4 108for details on how to specify which port range this corresponds to. 109.It Fl h Ar host 110The file to retrieve is located on the host 111.Ar host . 112This option is deprecated and is provided for backward compatibility 113only. 114.It Fl l 115If the target is a file-scheme URL, make a symbolic link to the target 116rather than trying to copy it. 117.It Fl M 118.It Fl m 119Mirror mode: if the file already exists locally and has the same size 120and modification time as the remote file, it will not be fetched. 121Note that the 122.Fl m 123and 124.Fl r 125flags are mutually exclusive. 126.It Fl n 127Don't preserve the modification time of the transferred file. 128.It Fl o Ar file 129Set the output file name to 130.Ar file . 131By default, a ``pathname'' is extracted from the specified URI, and 132its basename is used as the name of the output file. 133A 134.Ar file 135argument of 136.Sq Li \&- 137indicates that results are to be directed to the standard output. 138.It Fl P 139.It Fl p 140Use passive FTP. 141This is useful if you are behind a firewall which blocks incoming 142connections. 143Try this flag if 144.Nm 145seems to hang when retrieving FTP URLs. 146.It Fl q 147Quiet mode. 148.It Fl R 149The output files are precious, and should not be deleted under any 150circumstances, even if the transfer failed or was incomplete. 151.It Fl r 152Restart a previously interrupted transfer. 153Note that the 154.Fl m 155and 156.Fl r 157flags are mutually exclusive. 158.It Fl S Ar bytes 159Require the file size reported by the server to match the specified 160value. 161If it does not, a message is printed and the file is not fetched. 162If the server does not support reporting file sizes, this option is 163ignored and the file is fetched unconditionally. 164.It Fl s 165Print the size in bytes of each requested file, without fetching it. 166.It Fl T Ar seconds 167Set timeout value to 168.Ar seconds. 169Overrides the environment variables 170.Ev FTP_TIMEOUT 171for FTP transfers or 172.Ev HTTP_TIMEOUT 173for HTTP transfers if set. 174.It Fl v 175Increase verbosity level. 176.It Fl w Ar seconds 177When the 178.Fl a 179flag is specified, wait this many seconds between successive retries. 180.El 181.Sh DIAGNOSTICS 182The 183.Nm 184command returns zero on success, or one on failure. 185If multiple URLs are listed on the command line, 186.Nm 187will attempt to retrieve them each of them in turn, and return zero 188only if they were all successfully retrieved. 189.Sh ENVIRONMENT 190.Bl -tag -width FTP_PASSIVE_MODE -offset indent 191.It Ev FTP_TIMEOUT 192maximum time, in seconds, to wait before aborting an 193.Tn FTP 194connection. 195.It Ev HTTP_TIMEOUT 196maximum time, in seconds, to wait before aborting an 197.Tn HTTP 198connection. 199.El 200.Pp 201All environment variables mentioned in the documentation for the 202.Xr fetch 3 203library are supported. 204.Sh SEE ALSO 205.Xr fetch 3 206.Sh HISTORY 207The 208.Nm 209command appeared in 210.Fx 2.1.5 . 211This implementation first appeared in 212.Fx 4.1 . 213.Sh AUTHORS 214The original implementation of 215.Nm 216was done by 217.An Jean-Marc Zucconi . 218It was extensively re-worked for 219.Fx 2.2 220by 221.An Garrett Wollman , 222and later completely rewritten to use the 223.Xr fetch 3 224library by 225.An Dag-Erling Sm�rgrav . 226.Sh NOTES 227The 228.Fl b 229and 230.Fl t 231options are no longer supported and will generate warnings. 232They were workarounds for bugs in other OSes which this implementation 233does not trigger. 234.Pp 235One cannot both use the 236.Fl h , 237.Fl c 238and 239.Fl f 240options and specify URLs on the command line. 241