xref: /freebsd/usr.bin/fetch/fetch.1 (revision e801aa4856a79635e4da3e5690291ecab6f51df9)
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.\"
326ce729e1SRuslan Ermilov.Dd March 11, 2003
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
427dcb0a0eSDag-Erling Smørgrav.Op Fl N Ar file
437fefc698SJordan K. Hubbard.Op Fl o Ar file
44e801aa48SRuslan Ermilov.Op Fl S Ar bytes
45e801aa48SRuslan Ermilov.Op Fl T Ar seconds
46b39628e7SDag-Erling Smørgrav.Op Fl w Ar seconds
47e801aa48SRuslan Ermilov.Ar URL ...
48e801aa48SRuslan Ermilov.Nm
49e801aa48SRuslan Ermilov.Op Fl 146AadFlMmnPpqRrsUv
50e801aa48SRuslan Ermilov.Op Fl B Ar bytes
51e801aa48SRuslan Ermilov.Op Fl N Ar file
52e801aa48SRuslan Ermilov.Op Fl o Ar file
53e801aa48SRuslan Ermilov.Op Fl S Ar bytes
54e801aa48SRuslan Ermilov.Op Fl T Ar seconds
55e801aa48SRuslan Ermilov.Op Fl w Ar seconds
56e801aa48SRuslan Ermilov.Fl h Ar host Fl f Ar file Oo Fl c Ar dir Oc
577fefc698SJordan K. Hubbard.Sh DESCRIPTION
583898680cSPhilippe CharnierThe
593898680cSPhilippe Charnier.Nm
603898680cSPhilippe Charnierutility provides a command-line interface to the
61b39628e7SDag-Erling Smørgrav.Xr fetch 3
62b39628e7SDag-Erling Smørgravlibrary.
63b39628e7SDag-Erling SmørgravIts purpose is to retrieve the file(s) pointed to by the URL(s) on the
64b39628e7SDag-Erling Smørgravcommand line.
657fefc698SJordan K. Hubbard.Pp
667fefc698SJordan K. HubbardThe following options are available:
6776dafb89SGarrett Wollman.Bl -tag -width Fl
68e801aa48SRuslan Ermilov.It Fl 1
69b39628e7SDag-Erling SmørgravStop and return exit code 0 at the first successfully retrieved file.
70b39628e7SDag-Erling Smørgrav.It Fl 4
71b39628e7SDag-Erling SmørgravForces
72b39628e7SDag-Erling Smørgrav.Nm
73b39628e7SDag-Erling Smørgravto use IPv4 addresses only.
74b39628e7SDag-Erling Smørgrav.It Fl 6
75b39628e7SDag-Erling SmørgravForces
76b39628e7SDag-Erling Smørgrav.Nm
77b39628e7SDag-Erling Smørgravto use IPv6 addresses only.
78189da044SGarrett Wollman.It Fl A
79b39628e7SDag-Erling SmørgravDo not automatically follow ``temporary'' (302) redirects.
80b39628e7SDag-Erling SmørgravSome broken Web sites will return a redirect instead of a not-found
81b39628e7SDag-Erling Smørgraverror when the requested object does not exist.
822494e810SGarrett Wollman.It Fl a
832494e810SGarrett WollmanAutomatically retry the transfer upon soft failures.
84b39628e7SDag-Erling Smørgrav.It Fl B Ar bytes
85b39628e7SDag-Erling SmørgravSpecify the read buffer size in bytes.
86b39628e7SDag-Erling SmørgravThe default is 4096 bytes.
87b39628e7SDag-Erling SmørgravAttempts to set a buffer size lower than this will be silently
88b39628e7SDag-Erling Smørgravignored.
89b39628e7SDag-Erling SmørgravThe number of reads actually performed is reported at verbosity level
90b39628e7SDag-Erling Smørgravtwo or higher (see the
91b39628e7SDag-Erling Smørgrav.Fl v
92b39628e7SDag-Erling Smørgravflag).
9378be3199SGarrett Wollman.It Fl c Ar dir
9478be3199SGarrett WollmanThe file to retrieve is in directory
9578be3199SGarrett Wollman.Ar dir
9678be3199SGarrett Wollmanon the remote host.
97047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
98047843ddSDag-Erling Smørgravonly.
99047843ddSDag-Erling Smørgrav.It Fl d
100047843ddSDag-Erling SmørgravUse a direct connection even if a proxy is configured.
101d6a8296aSBrian Feldman.It Fl F
102b39628e7SDag-Erling SmørgravIn combination with the
103d6a8296aSBrian Feldman.Fl r
104b39628e7SDag-Erling Smørgravflag, forces a restart even if the local and remote files have
105b39628e7SDag-Erling Smørgravdifferent modification times.
1061bbb80b6SDag-Erling SmørgravImplies
1071bbb80b6SDag-Erling Smørgrav.Fl R .
10878be3199SGarrett Wollman.It Fl f Ar file
10978be3199SGarrett WollmanThe file to retrieve is named
11078be3199SGarrett Wollman.Ar file
11178be3199SGarrett Wollmanon the remote host.
112047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
113047843ddSDag-Erling Smørgravonly.
11478be3199SGarrett Wollman.It Fl h Ar host
11578be3199SGarrett WollmanThe file to retrieve is located on the host
11678be3199SGarrett Wollman.Ar host .
117047843ddSDag-Erling SmørgravThis option is deprecated and is provided for backward compatibility
118047843ddSDag-Erling Smørgravonly.
11978be3199SGarrett Wollman.It Fl l
120b39628e7SDag-Erling SmørgravIf the target is a file-scheme URL, make a symbolic link to the target
121b39628e7SDag-Erling Smørgravrather than trying to copy it.
1227fefc698SJordan K. Hubbard.It Fl M
1237fefc698SJordan K. Hubbard.It Fl m
1240b474bc6SDag-Erling SmørgravMirror mode: if the file already exists locally and has the same size
1250b474bc6SDag-Erling Smørgravand modification time as the remote file, it will not be fetched.
126c0b0d54eSDag-Erling SmørgravNote that the
127c0b0d54eSDag-Erling Smørgrav.Fl m
128c0b0d54eSDag-Erling Smørgravand
129c0b0d54eSDag-Erling Smørgrav.Fl r
130c0b0d54eSDag-Erling Smørgravflags are mutually exclusive.
1317dcb0a0eSDag-Erling Smørgrav.It Fl N Ar file
1327dcb0a0eSDag-Erling SmørgravUse
1337dcb0a0eSDag-Erling Smørgrav.Ar file
1347dcb0a0eSDag-Erling Smørgravinstead of
1357dcb0a0eSDag-Erling Smørgrav.Pa ~/.netrc
1367dcb0a0eSDag-Erling Smørgravto look up login names and passwords for FTP sites.
1377dcb0a0eSDag-Erling SmørgravSee
1387dcb0a0eSDag-Erling Smørgrav.Xr ftp 1
1397dcb0a0eSDag-Erling Smørgravfor a description of the file format.
1407dcb0a0eSDag-Erling SmørgravThis feature is experimental.
1416b5c2db2SJordan K. Hubbard.It Fl n
1420227791bSRuslan ErmilovDo not preserve the modification time of the transferred file.
14378be3199SGarrett Wollman.It Fl o Ar file
14478be3199SGarrett WollmanSet the output file name to
14578be3199SGarrett Wollman.Ar file .
14678be3199SGarrett WollmanBy default, a ``pathname'' is extracted from the specified URI, and
147b39628e7SDag-Erling Smørgravits basename is used as the name of the output file.
148b39628e7SDag-Erling SmørgravA
14978be3199SGarrett Wollman.Ar file
15078be3199SGarrett Wollmanargument of
15178be3199SGarrett Wollman.Sq Li \&-
15278be3199SGarrett Wollmanindicates that results are to be directed to the standard output.
153fe6a0485SColin PercivalIf the
154fe6a0485SColin Percival.Ar file
155fe6a0485SColin Percivalargument is a directory, fetched file(s) will be placed within the
156fe6a0485SColin Percivaldirectory, with name(s) selected as in the default behaviour.
1577fefc698SJordan K. Hubbard.It Fl P
1587fefc698SJordan K. Hubbard.It Fl p
159b39628e7SDag-Erling SmørgravUse passive FTP.
160b39628e7SDag-Erling SmørgravThis is useful if you are behind a firewall which blocks incoming
161b39628e7SDag-Erling Smørgravconnections.
162b39628e7SDag-Erling SmørgravTry this flag if
163b39628e7SDag-Erling Smørgrav.Nm
164b39628e7SDag-Erling Smørgravseems to hang when retrieving FTP URLs.
16578be3199SGarrett Wollman.It Fl q
16687faa07bSSheldon HearnQuiet mode.
16778be3199SGarrett Wollman.It Fl R
168b39628e7SDag-Erling SmørgravThe output files are precious, and should not be deleted under any
169b39628e7SDag-Erling Smørgravcircumstances, even if the transfer failed or was incomplete.
17078be3199SGarrett Wollman.It Fl r
17178be3199SGarrett WollmanRestart a previously interrupted transfer.
172c0b0d54eSDag-Erling SmørgravNote that the
173c0b0d54eSDag-Erling Smørgrav.Fl m
174c0b0d54eSDag-Erling Smørgravand
175c0b0d54eSDag-Erling Smørgrav.Fl r
176c0b0d54eSDag-Erling Smørgravflags are mutually exclusive.
1770637c2ccSJordan K. Hubbard.It Fl S Ar bytes
178b39628e7SDag-Erling SmørgravRequire the file size reported by the server to match the specified
179b39628e7SDag-Erling Smørgravvalue.
180b39628e7SDag-Erling SmørgravIf it does not, a message is printed and the file is not fetched.
181b39628e7SDag-Erling SmørgravIf the server does not support reporting file sizes, this option is
182b39628e7SDag-Erling Smørgravignored and the file is fetched unconditionally.
183b451f452SMartin Cracauer.It Fl s
184b39628e7SDag-Erling SmørgravPrint the size in bytes of each requested file, without fetching it.
185fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds
186fc6fcbf9SJordan K. HubbardSet timeout value to
187fc6fcbf9SJordan K. Hubbard.Ar seconds .
188a43a248cSPeter WemmOverrides the environment variables
189fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT
190b39628e7SDag-Erling Smørgravfor FTP transfers or
191a43a248cSPeter Wemm.Ev HTTP_TIMEOUT
192b39628e7SDag-Erling Smørgravfor HTTP transfers if set.
1937c480c6cSDag-Erling Smørgrav.It Fl U
1947c480c6cSDag-Erling SmørgravWhen using passive FTP, allocate the port for the data connection from
1957c480c6cSDag-Erling Smørgravthe low (default) port range.
1967c480c6cSDag-Erling SmørgravSee
1977c480c6cSDag-Erling Smørgrav.Xr ip 4
1987c480c6cSDag-Erling Smørgravfor details on how to specify which port range this corresponds to.
1997ae26f14SJordan K. Hubbard.It Fl v
20038a616e4SDag-Erling SmørgravIncrease verbosity level.
201b39628e7SDag-Erling Smørgrav.It Fl w Ar seconds
202b39628e7SDag-Erling SmørgravWhen the
203b39628e7SDag-Erling Smørgrav.Fl a
204b39628e7SDag-Erling Smørgravflag is specified, wait this many seconds between successive retries.
2057fefc698SJordan K. Hubbard.El
206ab47d799SRuslan Ermilov.Pp
207ab47d799SRuslan ErmilovIf
208ab47d799SRuslan Ermilov.Nm
209ab47d799SRuslan Ermilovreceives a
210ab47d799SRuslan Ermilov.Dv SIGINFO
211ab47d799SRuslan Ermilovsignal (see the
212ab47d799SRuslan Ermilov.Cm status
213ab47d799SRuslan Ermilovargument for
214ab47d799SRuslan Ermilov.Xr stty 1 ) ,
215ab47d799SRuslan Ermilovthe current transfer rate statistics will be written to the
216ab47d799SRuslan Ermilovstandard error output, in the same format as the standard completion
217ab47d799SRuslan Ermilovmessage.
2187fefc698SJordan K. Hubbard.Sh ENVIRONMENT
21909d2d42eSWes Peters.Bl -tag -width HTTP_TIMEOUT
22009d2d42eSWes Peters.It Ev FTP_TIMEOUT
2210fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an FTP connection.
22209d2d42eSWes Peters.It Ev HTTP_TIMEOUT
2230fc781ffSDag-Erling SmørgravMaximum time, in seconds, to wait before aborting an HTTP connection.
224cec5287bSWes Peters.El
22509d2d42eSWes Peters.Pp
2260fc781ffSDag-Erling SmørgravSee
22709d2d42eSWes Peters.Xr fetch 3
2280fc781ffSDag-Erling Smørgravfor a description of additional environment variables, including
2290fc781ffSDag-Erling Smørgrav.Ev FETCH_BIND_ADDRESS ,
2300fc781ffSDag-Erling Smørgrav.Ev FTP_LOGIN ,
2310fc781ffSDag-Erling Smørgrav.Ev FTP_PASSIVE_MODE ,
2320fc781ffSDag-Erling Smørgrav.Ev FTP_PASSWORD ,
2330fc781ffSDag-Erling Smørgrav.Ev FTP_PROXY ,
2340fc781ffSDag-Erling Smørgrav.Ev ftp_proxy ,
2350fc781ffSDag-Erling Smørgrav.Ev HTTP_AUTH ,
2360fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY ,
2370fc781ffSDag-Erling Smørgrav.Ev http_proxy ,
2380fc781ffSDag-Erling Smørgrav.Ev HTTP_PROXY_AUTH ,
2390fc781ffSDag-Erling Smørgrav.Ev HTTP_REFERER ,
2400fc781ffSDag-Erling Smørgrav.Ev HTTP_USER_AGENT ,
2410fc781ffSDag-Erling Smørgrav.Ev NETRC ,
2420fc781ffSDag-Erling Smørgrav.Ev NO_PROXY and
2430fc781ffSDag-Erling Smørgrav.Ev no_proxy .
2446c7216dfSRuslan Ermilov.Sh EXIT STATUS
2456c7216dfSRuslan ErmilovThe
2466c7216dfSRuslan Ermilov.Nm
2476c7216dfSRuslan Ermilovcommand returns zero on success, or one on failure.
2486c7216dfSRuslan ErmilovIf multiple URLs are listed on the command line,
2496c7216dfSRuslan Ermilov.Nm
250ee8e4b36SJoseph Koshywill attempt to retrieve each one of them in turn, and will return
251ee8e4b36SJoseph Koshyzero only if they were all successfully retrieved.
2527fefc698SJordan K. Hubbard.Sh SEE ALSO
253b39628e7SDag-Erling Smørgrav.Xr fetch 3
2547fefc698SJordan K. Hubbard.Sh HISTORY
2557fefc698SJordan K. HubbardThe
256b39628e7SDag-Erling Smørgrav.Nm
25785cf659aSMike Pritchardcommand appeared in
25885cf659aSMike Pritchard.Fx 2.1.5 .
259b39628e7SDag-Erling SmørgravThis implementation first appeared in
260b39628e7SDag-Erling Smørgrav.Fx 4.1 .
26178be3199SGarrett Wollman.Sh AUTHORS
262f4d874a1SRuslan Ermilov.An -nosplit
26378be3199SGarrett WollmanThe original implementation of
26478be3199SGarrett Wollman.Nm
265306005e7SPhilippe Charnierwas done by
26609e06539SDag-Erling Smørgrav.An Jean-Marc Zucconi Aq jmz@FreeBSD.org .
267306005e7SPhilippe CharnierIt was extensively re-worked for
268bc5d5816SWolfram Schneider.Fx 2.2
269306005e7SPhilippe Charnierby
27009e06539SDag-Erling Smørgrav.An Garrett Wollman Aq wollman@FreeBSD.org ,
271b39628e7SDag-Erling Smørgravand later completely rewritten to use the
272b39628e7SDag-Erling Smørgrav.Xr fetch 3
273b39628e7SDag-Erling Smørgravlibrary by
27490ffd7eaSDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
275b39628e7SDag-Erling Smørgrav.Sh NOTES
2762494e810SGarrett WollmanThe
2770c8cc99eSGarrett Wollman.Fl b
278b39628e7SDag-Erling Smørgravand
279b39628e7SDag-Erling Smørgrav.Fl t
280b39628e7SDag-Erling Smørgravoptions are no longer supported and will generate warnings.
281b39628e7SDag-Erling SmørgravThey were workarounds for bugs in other OSes which this implementation
282b39628e7SDag-Erling Smørgravdoes not trigger.
283c1468430SGarrett Wollman.Pp
284047843ddSDag-Erling SmørgravOne cannot both use the
285047843ddSDag-Erling Smørgrav.Fl h ,
286cf575052SBen Smithurst.Fl c
287cf575052SBen Smithurstand
288b39628e7SDag-Erling Smørgrav.Fl f
289047843ddSDag-Erling Smørgravoptions and specify URLs on the command line.
290