xref: /freebsd/usr.bin/fetch/fetch.1 (revision 7f92799f678efdf44f0f4d3322f49498749e4468)
1b39628e7SDag-Erling Smørgrav.\"-
22cbbf9daSDag-Erling Smørgrav.\" Copyright (c) 2000-2004 Dag-Erling Co�dan 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.\"
327f92799fSMurray Stokely.Dd December 14, 2008
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.
168b39628e7SDag-Erling SmørgravThis is useful if you are behind a firewall which blocks incoming
169b39628e7SDag-Erling Smørgravconnections.
170b39628e7SDag-Erling SmørgravTry this flag if
171b39628e7SDag-Erling Smørgrav.Nm
172b39628e7SDag-Erling Smørgravseems to hang when retrieving FTP URLs.
17378be3199SGarrett Wollman.It Fl q
17487faa07bSSheldon HearnQuiet mode.
17578be3199SGarrett Wollman.It Fl R
176b39628e7SDag-Erling SmørgravThe output files are precious, and should not be deleted under any
177b39628e7SDag-Erling Smørgravcircumstances, even if the transfer failed or was incomplete.
17878be3199SGarrett Wollman.It Fl r
17978be3199SGarrett WollmanRestart a previously interrupted transfer.
180c0b0d54eSDag-Erling SmørgravNote that the
181c0b0d54eSDag-Erling Smørgrav.Fl m
182c0b0d54eSDag-Erling Smørgravand
183c0b0d54eSDag-Erling Smørgrav.Fl r
184c0b0d54eSDag-Erling Smørgravflags are mutually exclusive.
1850637c2ccSJordan K. Hubbard.It Fl S Ar bytes
186b39628e7SDag-Erling SmørgravRequire the file size reported by the server to match the specified
187b39628e7SDag-Erling Smørgravvalue.
188b39628e7SDag-Erling SmørgravIf it does not, a message is printed and the file is not fetched.
189b39628e7SDag-Erling SmørgravIf the server does not support reporting file sizes, this option is
190b39628e7SDag-Erling Smørgravignored and the file is fetched unconditionally.
191b451f452SMartin Cracauer.It Fl s
192b39628e7SDag-Erling SmørgravPrint the size in bytes of each requested file, without fetching it.
193fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds
194fc6fcbf9SJordan K. HubbardSet timeout value to
195fc6fcbf9SJordan K. Hubbard.Ar seconds .
196a43a248cSPeter WemmOverrides the environment variables
197fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT
198b39628e7SDag-Erling Smørgravfor FTP transfers or
199a43a248cSPeter Wemm.Ev HTTP_TIMEOUT
200b39628e7SDag-Erling Smørgravfor HTTP transfers if set.
2017c480c6cSDag-Erling Smørgrav.It Fl U
2027c480c6cSDag-Erling SmørgravWhen using passive FTP, allocate the port for the data connection from
2037c480c6cSDag-Erling Smørgravthe low (default) port range.
2047c480c6cSDag-Erling SmørgravSee
2057c480c6cSDag-Erling Smørgrav.Xr ip 4
2067c480c6cSDag-Erling Smørgravfor details on how to specify which port range this corresponds to.
2077ae26f14SJordan K. Hubbard.It Fl v
20838a616e4SDag-Erling SmørgravIncrease verbosity level.
209b39628e7SDag-Erling Smørgrav.It Fl w Ar seconds
210b39628e7SDag-Erling SmørgravWhen the
211b39628e7SDag-Erling Smørgrav.Fl a
212b39628e7SDag-Erling Smørgravflag is specified, wait this many seconds between successive retries.
2137fefc698SJordan K. Hubbard.El
214ab47d799SRuslan Ermilov.Pp
215ab47d799SRuslan ErmilovIf
216ab47d799SRuslan Ermilov.Nm
217ab47d799SRuslan Ermilovreceives a
218ab47d799SRuslan Ermilov.Dv SIGINFO
219ab47d799SRuslan Ermilovsignal (see the
220ab47d799SRuslan Ermilov.Cm status
221ab47d799SRuslan Ermilovargument for
222ab47d799SRuslan Ermilov.Xr stty 1 ) ,
223ab47d799SRuslan Ermilovthe current transfer rate statistics will be written to the
224ab47d799SRuslan Ermilovstandard error output, in the same format as the standard completion
225ab47d799SRuslan Ermilovmessage.
2267fefc698SJordan K. Hubbard.Sh ENVIRONMENT
22709d2d42eSWes Peters.Bl -tag -width HTTP_TIMEOUT
22809d2d42eSWes Peters.It Ev FTP_TIMEOUT
2290fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an FTP connection.
23009d2d42eSWes Peters.It Ev HTTP_TIMEOUT
2310fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an HTTP connection.
232cec5287bSWes Peters.El
23309d2d42eSWes Peters.Pp
2340fc781ffSDag-Erling SmørgravSee
23509d2d42eSWes Peters.Xr fetch 3
2360fc781ffSDag-Erling Smørgravfor a description of additional environment variables, including
2370fc781ffSDag-Erling Smørgrav.Ev FETCH_BIND_ADDRESS ,
2380fc781ffSDag-Erling Smørgrav.Ev FTP_LOGIN ,
2390fc781ffSDag-Erling Smørgrav.Ev FTP_PASSIVE_MODE ,
2400fc781ffSDag-Erling Smørgrav.Ev FTP_PASSWORD ,
2410fc781ffSDag-Erling Smørgrav.Ev FTP_PROXY ,
2420fc781ffSDag-Erling Smørgrav.Ev ftp_proxy ,
2430fc781ffSDag-Erling Smørgrav.Ev HTTP_AUTH ,
2440fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY ,
2450fc781ffSDag-Erling Smørgrav.Ev http_proxy ,
2460fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY_AUTH ,
2470fc781ffSDag-Erling Smørgrav.Ev HTTP_REFERER ,
2480fc781ffSDag-Erling Smørgrav.Ev HTTP_USER_AGENT ,
2490fc781ffSDag-Erling Smørgrav.Ev NETRC ,
2500fc781ffSDag-Erling Smørgrav.Ev NO_PROXY and
2510fc781ffSDag-Erling Smørgrav.Ev no_proxy .
2526c7216dfSRuslan Ermilov.Sh EXIT STATUS
2536c7216dfSRuslan ErmilovThe
2546c7216dfSRuslan Ermilov.Nm
2556c7216dfSRuslan Ermilovcommand returns zero on success, or one on failure.
2566c7216dfSRuslan ErmilovIf multiple URLs are listed on the command line,
2576c7216dfSRuslan Ermilov.Nm
258ee8e4b36SJoseph Koshywill attempt to retrieve each one of them in turn, and will return
259ee8e4b36SJoseph Koshyzero only if they were all successfully retrieved.
2607f92799fSMurray Stokely.Pp
2617f92799fSMurray StokelyIf the
2627f92799fSMurray Stokely.Fl i
2637f92799fSMurray Stokelyargument is used and the remote file is not newer than the
2647f92799fSMurray Stokelyspecified file then the command will still return success,
2657f92799fSMurray Stokelyalthough no file is transferred.
2667fefc698SJordan K. Hubbard.Sh SEE ALSO
267b39628e7SDag-Erling Smørgrav.Xr fetch 3
2687fefc698SJordan K. Hubbard.Sh HISTORY
2697fefc698SJordan K. HubbardThe
270b39628e7SDag-Erling Smørgrav.Nm
27185cf659aSMike Pritchardcommand appeared in
27285cf659aSMike Pritchard.Fx 2.1.5 .
273b39628e7SDag-Erling SmørgravThis implementation first appeared in
274b39628e7SDag-Erling Smørgrav.Fx 4.1 .
27578be3199SGarrett Wollman.Sh AUTHORS
276f4d874a1SRuslan Ermilov.An -nosplit
27778be3199SGarrett WollmanThe original implementation of
27878be3199SGarrett Wollman.Nm
279306005e7SPhilippe Charnierwas done by
28009e06539SDag-Erling Smørgrav.An Jean-Marc Zucconi Aq jmz@FreeBSD.org .
281306005e7SPhilippe CharnierIt was extensively re-worked for
282bc5d5816SWolfram Schneider.Fx 2.2
283306005e7SPhilippe Charnierby
28409e06539SDag-Erling Smørgrav.An Garrett Wollman Aq wollman@FreeBSD.org ,
285b39628e7SDag-Erling Smørgravand later completely rewritten to use the
286b39628e7SDag-Erling Smørgrav.Xr fetch 3
287b39628e7SDag-Erling Smørgravlibrary by
28890ffd7eaSDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
289b39628e7SDag-Erling Smørgrav.Sh NOTES
2902494e810SGarrett WollmanThe
2910c8cc99eSGarrett Wollman.Fl b
292b39628e7SDag-Erling Smørgravand
293b39628e7SDag-Erling Smørgrav.Fl t
294b39628e7SDag-Erling Smørgravoptions are no longer supported and will generate warnings.
295b39628e7SDag-Erling SmørgravThey were workarounds for bugs in other OSes which this implementation
296b39628e7SDag-Erling Smørgravdoes not trigger.
297c1468430SGarrett Wollman.Pp
298047843ddSDag-Erling SmørgravOne cannot both use the
299047843ddSDag-Erling Smørgrav.Fl h ,
300cf575052SBen Smithurst.Fl c
301cf575052SBen Smithurstand
302b39628e7SDag-Erling Smørgrav.Fl f
303047843ddSDag-Erling Smørgravoptions and specify URLs on the command line.
304