xref: /freebsd/usr.bin/fetch/fetch.1 (revision 011a8335f86b11562f4913d385ff11a6b9331495)
1b39628e7SDag-Erling Smørgrav.\"-
20ce8603cSDag-Erling Smørgrav.\" Copyright (c) 2000-2011 Dag-Erling Smørgrav
3b39628e7SDag-Erling Smørgrav.\" All rights reserved.
4114c3c1aSDag-Erling Smørgrav.\" Portions Copyright (c) 1999 Massachusetts Institute of Technology; used
5114c3c1aSDag-Erling Smørgrav.\" by permission.
6b39628e7SDag-Erling Smørgrav.\"
7b39628e7SDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
8b39628e7SDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
9b39628e7SDag-Erling Smørgrav.\" are met:
10b39628e7SDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
11b39628e7SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer
12b39628e7SDag-Erling Smørgrav.\"    in this position and unchanged.
13b39628e7SDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
14b39628e7SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
15b39628e7SDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
16b39628e7SDag-Erling Smørgrav.\" 3. The name of the author may not be used to endorse or promote products
17b39628e7SDag-Erling Smørgrav.\"    derived from this software without specific prior written permission.
18b39628e7SDag-Erling Smørgrav.\"
19b39628e7SDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20b39628e7SDag-Erling Smørgrav.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21b39628e7SDag-Erling Smørgrav.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22b39628e7SDag-Erling Smørgrav.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23b39628e7SDag-Erling Smørgrav.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24b39628e7SDag-Erling Smørgrav.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25b39628e7SDag-Erling Smørgrav.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26b39628e7SDag-Erling Smørgrav.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27b39628e7SDag-Erling Smørgrav.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28b39628e7SDag-Erling Smørgrav.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29b39628e7SDag-Erling Smørgrav.\"
30c3aac50fSPeter Wemm.\" $FreeBSD$
31b39628e7SDag-Erling Smørgrav.\"
320ce8603cSDag-Erling Smørgrav.Dd September 27, 2011
337fefc698SJordan K. Hubbard.Dt FETCH 1
34b39628e7SDag-Erling Smørgrav.Os
357fefc698SJordan K. Hubbard.Sh NAME
367fefc698SJordan K. Hubbard.Nm fetch
377fefc698SJordan K. Hubbard.Nd retrieve a file by Uniform Resource Locator
387fefc698SJordan K. Hubbard.Sh SYNOPSIS
39b39628e7SDag-Erling Smørgrav.Nm
40e801aa48SRuslan Ermilov.Op Fl 146AadFlMmnPpqRrsUv
41b39628e7SDag-Erling Smørgrav.Op Fl B Ar bytes
427f92799fSMurray Stokely.Op Fl i Ar file
437dcb0a0eSDag-Erling Smørgrav.Op Fl N Ar file
447fefc698SJordan K. Hubbard.Op Fl o Ar file
45e801aa48SRuslan Ermilov.Op Fl S Ar bytes
46e801aa48SRuslan Ermilov.Op Fl T Ar seconds
47b39628e7SDag-Erling Smørgrav.Op Fl w Ar seconds
48e801aa48SRuslan Ermilov.Ar URL ...
49e801aa48SRuslan Ermilov.Nm
50e801aa48SRuslan Ermilov.Op Fl 146AadFlMmnPpqRrsUv
51e801aa48SRuslan Ermilov.Op Fl B Ar bytes
527f92799fSMurray Stokely.Op Fl i Ar file
53e801aa48SRuslan Ermilov.Op Fl N Ar file
54e801aa48SRuslan Ermilov.Op Fl o Ar file
55e801aa48SRuslan Ermilov.Op Fl S Ar bytes
56e801aa48SRuslan Ermilov.Op Fl T Ar seconds
57e801aa48SRuslan Ermilov.Op Fl w Ar seconds
58e801aa48SRuslan Ermilov.Fl h Ar host Fl f Ar file Oo Fl c Ar dir Oc
597fefc698SJordan K. Hubbard.Sh DESCRIPTION
603898680cSPhilippe CharnierThe
613898680cSPhilippe Charnier.Nm
623898680cSPhilippe Charnierutility provides a command-line interface to the
63b39628e7SDag-Erling Smørgrav.Xr fetch 3
64b39628e7SDag-Erling Smørgravlibrary.
65b39628e7SDag-Erling SmørgravIts purpose is to retrieve the file(s) pointed to by the URL(s) on the
66b39628e7SDag-Erling Smørgravcommand line.
677fefc698SJordan K. Hubbard.Pp
687fefc698SJordan K. HubbardThe following options are available:
6976dafb89SGarrett Wollman.Bl -tag -width Fl
70e801aa48SRuslan Ermilov.It Fl 1
71b39628e7SDag-Erling SmørgravStop and return exit code 0 at the first successfully retrieved file.
72b39628e7SDag-Erling Smørgrav.It Fl 4
73b39628e7SDag-Erling SmørgravForces
74b39628e7SDag-Erling Smørgrav.Nm
75b39628e7SDag-Erling Smørgravto use IPv4 addresses only.
76b39628e7SDag-Erling Smørgrav.It Fl 6
77b39628e7SDag-Erling SmørgravForces
78b39628e7SDag-Erling Smørgrav.Nm
79b39628e7SDag-Erling Smørgravto use IPv6 addresses only.
80189da044SGarrett Wollman.It Fl A
81b39628e7SDag-Erling SmørgravDo not automatically follow ``temporary'' (302) redirects.
82b39628e7SDag-Erling SmørgravSome broken Web sites will return a redirect instead of a not-found
83b39628e7SDag-Erling Smørgraverror when the requested object does not exist.
842494e810SGarrett Wollman.It Fl a
852494e810SGarrett WollmanAutomatically retry the transfer upon soft failures.
86b39628e7SDag-Erling Smørgrav.It Fl B Ar bytes
87b39628e7SDag-Erling SmørgravSpecify the read buffer size in bytes.
88b39628e7SDag-Erling SmørgravThe default is 4096 bytes.
89b39628e7SDag-Erling SmørgravAttempts to set a buffer size lower than this will be silently
90b39628e7SDag-Erling Smørgravignored.
91b39628e7SDag-Erling SmørgravThe number of reads actually performed is reported at verbosity level
92b39628e7SDag-Erling Smørgravtwo or higher (see the
93b39628e7SDag-Erling Smørgrav.Fl v
94b39628e7SDag-Erling Smørgravflag).
9578be3199SGarrett Wollman.It Fl c Ar dir
9678be3199SGarrett WollmanThe file to retrieve is in directory
9778be3199SGarrett Wollman.Ar dir
9878be3199SGarrett Wollmanon the remote host.
99047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
100047843ddSDag-Erling Smørgravonly.
101047843ddSDag-Erling Smørgrav.It Fl d
102047843ddSDag-Erling SmørgravUse a direct connection even if a proxy is configured.
103d6a8296aSBrian Feldman.It Fl F
104b39628e7SDag-Erling SmørgravIn combination with the
105d6a8296aSBrian Feldman.Fl r
106b39628e7SDag-Erling Smørgravflag, forces a restart even if the local and remote files have
107b39628e7SDag-Erling Smørgravdifferent modification times.
1081bbb80b6SDag-Erling SmørgravImplies
1091bbb80b6SDag-Erling Smørgrav.Fl R .
11078be3199SGarrett Wollman.It Fl f Ar file
11178be3199SGarrett WollmanThe file to retrieve is named
11278be3199SGarrett Wollman.Ar file
11378be3199SGarrett Wollmanon the remote host.
114047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
115047843ddSDag-Erling Smørgravonly.
11678be3199SGarrett Wollman.It Fl h Ar host
11778be3199SGarrett WollmanThe file to retrieve is located on the host
11878be3199SGarrett Wollman.Ar host .
119047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
120047843ddSDag-Erling Smørgravonly.
1217f92799fSMurray Stokely.It Fl i Ar file
1227f92799fSMurray StokelyIf-Modified-Since mode: the remote file will only be retrieved if it
1237f92799fSMurray Stokelyis newer than
1247f92799fSMurray Stokely.Ar file
1257f92799fSMurray Stokelyon the local host.
1267f92799fSMurray Stokely(HTTP only)
12778be3199SGarrett Wollman.It Fl l
128b39628e7SDag-Erling SmørgravIf the target is a file-scheme URL, make a symbolic link to the target
129b39628e7SDag-Erling Smørgravrather than trying to copy it.
1307fefc698SJordan K. Hubbard.It Fl M
1317fefc698SJordan K. Hubbard.It Fl m
1320b474bc6SDag-Erling SmørgravMirror mode: if the file already exists locally and has the same size
1330b474bc6SDag-Erling Smørgravand modification time as the remote file, it will not be fetched.
134c0b0d54eSDag-Erling SmørgravNote that the
135c0b0d54eSDag-Erling Smørgrav.Fl m
136c0b0d54eSDag-Erling Smørgravand
137c0b0d54eSDag-Erling Smørgrav.Fl r
138c0b0d54eSDag-Erling Smørgravflags are mutually exclusive.
1397dcb0a0eSDag-Erling Smørgrav.It Fl N Ar file
1407dcb0a0eSDag-Erling SmørgravUse
1417dcb0a0eSDag-Erling Smørgrav.Ar file
1427dcb0a0eSDag-Erling Smørgravinstead of
1437dcb0a0eSDag-Erling Smørgrav.Pa ~/.netrc
1447dcb0a0eSDag-Erling Smørgravto look up login names and passwords for FTP sites.
1457dcb0a0eSDag-Erling SmørgravSee
1467dcb0a0eSDag-Erling Smørgrav.Xr ftp 1
1477dcb0a0eSDag-Erling Smørgravfor a description of the file format.
1487dcb0a0eSDag-Erling SmørgravThis feature is experimental.
1496b5c2db2SJordan K. Hubbard.It Fl n
1500227791bSRuslan ErmilovDo not preserve the modification time of the transferred file.
15178be3199SGarrett Wollman.It Fl o Ar file
15278be3199SGarrett WollmanSet the output file name to
15378be3199SGarrett Wollman.Ar file .
15478be3199SGarrett WollmanBy default, a ``pathname'' is extracted from the specified URI, and
155b39628e7SDag-Erling Smørgravits basename is used as the name of the output file.
156b39628e7SDag-Erling SmørgravA
15778be3199SGarrett Wollman.Ar file
15878be3199SGarrett Wollmanargument of
15978be3199SGarrett Wollman.Sq Li \&-
16078be3199SGarrett Wollmanindicates that results are to be directed to the standard output.
161fe6a0485SColin PercivalIf the
162fe6a0485SColin Percival.Ar file
163fe6a0485SColin Percivalargument is a directory, fetched file(s) will be placed within the
164fe6a0485SColin Percivaldirectory, with name(s) selected as in the default behaviour.
1657fefc698SJordan K. Hubbard.It Fl P
1667fefc698SJordan K. Hubbard.It Fl p
167b39628e7SDag-Erling SmørgravUse passive FTP.
168bb6e3329SDag-Erling SmørgravThese flags have no effect, since passive FTP is the default, but are
169bb6e3329SDag-Erling Smørgravprovided for compatibility with earlier versions where active FTP was
170bb6e3329SDag-Erling Smørgravthe default.
171bb6e3329SDag-Erling SmørgravTo force active mode, set the
172bb6e3329SDag-Erling Smørgrav.Ev FTP_PASSIVE_MODE
173bb6e3329SDag-Erling Smørgravenvironment variable to
174bb6e3329SDag-Erling Smørgrav.Ql NO .
17578be3199SGarrett Wollman.It Fl q
17687faa07bSSheldon HearnQuiet mode.
17778be3199SGarrett Wollman.It Fl R
178b39628e7SDag-Erling SmørgravThe output files are precious, and should not be deleted under any
179b39628e7SDag-Erling Smørgravcircumstances, even if the transfer failed or was incomplete.
18078be3199SGarrett Wollman.It Fl r
18178be3199SGarrett WollmanRestart a previously interrupted transfer.
182c0b0d54eSDag-Erling SmørgravNote that the
183c0b0d54eSDag-Erling Smørgrav.Fl m
184c0b0d54eSDag-Erling Smørgravand
185c0b0d54eSDag-Erling Smørgrav.Fl r
186c0b0d54eSDag-Erling Smørgravflags are mutually exclusive.
1870637c2ccSJordan K. Hubbard.It Fl S Ar bytes
188b39628e7SDag-Erling SmørgravRequire the file size reported by the server to match the specified
189b39628e7SDag-Erling Smørgravvalue.
190b39628e7SDag-Erling SmørgravIf it does not, a message is printed and the file is not fetched.
191b39628e7SDag-Erling SmørgravIf the server does not support reporting file sizes, this option is
192b39628e7SDag-Erling Smørgravignored and the file is fetched unconditionally.
193b451f452SMartin Cracauer.It Fl s
194b39628e7SDag-Erling SmørgravPrint the size in bytes of each requested file, without fetching it.
195fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds
196fc6fcbf9SJordan K. HubbardSet timeout value to
197fc6fcbf9SJordan K. Hubbard.Ar seconds .
198a43a248cSPeter WemmOverrides the environment variables
199fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT
200b39628e7SDag-Erling Smørgravfor FTP transfers or
201a43a248cSPeter Wemm.Ev HTTP_TIMEOUT
202b39628e7SDag-Erling Smørgravfor HTTP transfers if set.
2037c480c6cSDag-Erling Smørgrav.It Fl U
2047c480c6cSDag-Erling SmørgravWhen using passive FTP, allocate the port for the data connection from
2057c480c6cSDag-Erling Smørgravthe low (default) port range.
2067c480c6cSDag-Erling SmørgravSee
2077c480c6cSDag-Erling Smørgrav.Xr ip 4
2087c480c6cSDag-Erling Smørgravfor details on how to specify which port range this corresponds to.
2097ae26f14SJordan K. Hubbard.It Fl v
21038a616e4SDag-Erling SmørgravIncrease verbosity level.
211b39628e7SDag-Erling Smørgrav.It Fl w Ar seconds
212b39628e7SDag-Erling SmørgravWhen the
213b39628e7SDag-Erling Smørgrav.Fl a
214b39628e7SDag-Erling Smørgravflag is specified, wait this many seconds between successive retries.
2157fefc698SJordan K. Hubbard.El
216ab47d799SRuslan Ermilov.Pp
217ab47d799SRuslan ErmilovIf
218ab47d799SRuslan Ermilov.Nm
219ab47d799SRuslan Ermilovreceives a
220ab47d799SRuslan Ermilov.Dv SIGINFO
221ab47d799SRuslan Ermilovsignal (see the
222ab47d799SRuslan Ermilov.Cm status
223ab47d799SRuslan Ermilovargument for
224ab47d799SRuslan Ermilov.Xr stty 1 ) ,
225ab47d799SRuslan Ermilovthe current transfer rate statistics will be written to the
226ab47d799SRuslan Ermilovstandard error output, in the same format as the standard completion
227ab47d799SRuslan Ermilovmessage.
2287fefc698SJordan K. Hubbard.Sh ENVIRONMENT
22909d2d42eSWes Peters.Bl -tag -width HTTP_TIMEOUT
23009d2d42eSWes Peters.It Ev FTP_TIMEOUT
2310fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an FTP connection.
23209d2d42eSWes Peters.It Ev HTTP_TIMEOUT
2330fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an HTTP connection.
234cec5287bSWes Peters.El
23509d2d42eSWes Peters.Pp
2360fc781ffSDag-Erling SmørgravSee
23709d2d42eSWes Peters.Xr fetch 3
2380fc781ffSDag-Erling Smørgravfor a description of additional environment variables, including
2390fc781ffSDag-Erling Smørgrav.Ev FETCH_BIND_ADDRESS ,
2400fc781ffSDag-Erling Smørgrav.Ev FTP_LOGIN ,
2410fc781ffSDag-Erling Smørgrav.Ev FTP_PASSIVE_MODE ,
2420fc781ffSDag-Erling Smørgrav.Ev FTP_PASSWORD ,
2430fc781ffSDag-Erling Smørgrav.Ev FTP_PROXY ,
2440fc781ffSDag-Erling Smørgrav.Ev ftp_proxy ,
2450fc781ffSDag-Erling Smørgrav.Ev HTTP_AUTH ,
2460fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY ,
2470fc781ffSDag-Erling Smørgrav.Ev http_proxy ,
2480fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY_AUTH ,
2490fc781ffSDag-Erling Smørgrav.Ev HTTP_REFERER ,
2500fc781ffSDag-Erling Smørgrav.Ev HTTP_USER_AGENT ,
2510fc781ffSDag-Erling Smørgrav.Ev NETRC ,
252*011a8335SDag-Erling Smørgrav.Ev NO_PROXY
253*011a8335SDag-Erling Smørgravand
2540fc781ffSDag-Erling Smørgrav.Ev no_proxy .
2556c7216dfSRuslan Ermilov.Sh EXIT STATUS
2566c7216dfSRuslan ErmilovThe
2576c7216dfSRuslan Ermilov.Nm
2586c7216dfSRuslan Ermilovcommand returns zero on success, or one on failure.
2596c7216dfSRuslan ErmilovIf multiple URLs are listed on the command line,
2606c7216dfSRuslan Ermilov.Nm
261ee8e4b36SJoseph Koshywill attempt to retrieve each one of them in turn, and will return
262ee8e4b36SJoseph Koshyzero only if they were all successfully retrieved.
2637f92799fSMurray Stokely.Pp
2647f92799fSMurray StokelyIf the
2657f92799fSMurray Stokely.Fl i
2667f92799fSMurray Stokelyargument is used and the remote file is not newer than the
2677f92799fSMurray Stokelyspecified file then the command will still return success,
2687f92799fSMurray Stokelyalthough no file is transferred.
2697fefc698SJordan K. Hubbard.Sh SEE ALSO
270b39628e7SDag-Erling Smørgrav.Xr fetch 3
2717fefc698SJordan K. Hubbard.Sh HISTORY
2727fefc698SJordan K. HubbardThe
273b39628e7SDag-Erling Smørgrav.Nm
27485cf659aSMike Pritchardcommand appeared in
27585cf659aSMike Pritchard.Fx 2.1.5 .
276b39628e7SDag-Erling SmørgravThis implementation first appeared in
277b39628e7SDag-Erling Smørgrav.Fx 4.1 .
27878be3199SGarrett Wollman.Sh AUTHORS
279f4d874a1SRuslan Ermilov.An -nosplit
28078be3199SGarrett WollmanThe original implementation of
28178be3199SGarrett Wollman.Nm
282306005e7SPhilippe Charnierwas done by
28309e06539SDag-Erling Smørgrav.An Jean-Marc Zucconi Aq jmz@FreeBSD.org .
284306005e7SPhilippe CharnierIt was extensively re-worked for
285bc5d5816SWolfram Schneider.Fx 2.2
286306005e7SPhilippe Charnierby
28709e06539SDag-Erling Smørgrav.An Garrett Wollman Aq wollman@FreeBSD.org ,
288b39628e7SDag-Erling Smørgravand later completely rewritten to use the
289b39628e7SDag-Erling Smørgrav.Xr fetch 3
290b39628e7SDag-Erling Smørgravlibrary by
29190ffd7eaSDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
292b39628e7SDag-Erling Smørgrav.Sh NOTES
2932494e810SGarrett WollmanThe
2940c8cc99eSGarrett Wollman.Fl b
295b39628e7SDag-Erling Smørgravand
296b39628e7SDag-Erling Smørgrav.Fl t
297b39628e7SDag-Erling Smørgravoptions are no longer supported and will generate warnings.
298b39628e7SDag-Erling SmørgravThey were workarounds for bugs in other OSes which this implementation
299b39628e7SDag-Erling Smørgravdoes not trigger.
300c1468430SGarrett Wollman.Pp
301047843ddSDag-Erling SmørgravOne cannot both use the
302047843ddSDag-Erling Smørgrav.Fl h ,
303cf575052SBen Smithurst.Fl c
304cf575052SBen Smithurstand
305b39628e7SDag-Erling Smørgrav.Fl f
306047843ddSDag-Erling Smørgravoptions and specify URLs on the command line.
307