]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - usr.bin/fetch/fetch.1
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / usr.bin / fetch / fetch.1
1 .\"-
2 .\" Copyright (c) 2000-2004 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 December 14, 2008
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 146AadFlMmnPpqRrsUv
41 .Op Fl B Ar bytes
42 .Op Fl i Ar file
43 .Op Fl N Ar file
44 .Op Fl o Ar file
45 .Op Fl S Ar bytes
46 .Op Fl T Ar seconds
47 .Op Fl w Ar seconds
48 .Ar URL ...
49 .Nm
50 .Op Fl 146AadFlMmnPpqRrsUv
51 .Op Fl B Ar bytes
52 .Op Fl i Ar file
53 .Op Fl N Ar file
54 .Op Fl o Ar file
55 .Op Fl S Ar bytes
56 .Op Fl T Ar seconds
57 .Op Fl w Ar seconds
58 .Fl h Ar host Fl f Ar file Oo Fl c Ar dir Oc
59 .Sh DESCRIPTION
60 The
61 .Nm
62 utility provides a command-line interface to the
63 .Xr fetch 3
64 library.
65 Its purpose is to retrieve the file(s) pointed to by the URL(s) on the
66 command line.
67 .Pp
68 The following options are available:
69 .Bl -tag -width Fl
70 .It Fl 1
71 Stop and return exit code 0 at the first successfully retrieved file.
72 .It Fl 4
73 Forces
74 .Nm
75 to use IPv4 addresses only.
76 .It Fl 6
77 Forces
78 .Nm
79 to use IPv6 addresses only.
80 .It Fl A
81 Do not automatically follow ``temporary'' (302) redirects.
82 Some broken Web sites will return a redirect instead of a not-found
83 error when the requested object does not exist.
84 .It Fl a
85 Automatically retry the transfer upon soft failures.
86 .It Fl B Ar bytes
87 Specify the read buffer size in bytes.
88 The default is 4096 bytes.
89 Attempts to set a buffer size lower than this will be silently
90 ignored.
91 The number of reads actually performed is reported at verbosity level
92 two or higher (see the
93 .Fl v
94 flag).
95 .It Fl c Ar dir
96 The file to retrieve is in directory
97 .Ar dir
98 on the remote host.
99 This option is deprecated and is provided for backward compatibility
100 only.
101 .It Fl d
102 Use a direct connection even if a proxy is configured.
103 .It Fl F
104 In combination with the
105 .Fl r
106 flag, forces a restart even if the local and remote files have
107 different modification times.
108 Implies
109 .Fl R .
110 .It Fl f Ar file
111 The file to retrieve is named
112 .Ar file
113 on the remote host.
114 This option is deprecated and is provided for backward compatibility
115 only.
116 .It Fl h Ar host
117 The file to retrieve is located on the host
118 .Ar host .
119 This option is deprecated and is provided for backward compatibility
120 only.
121 .It Fl i Ar file
122 If-Modified-Since mode: the remote file will only be retrieved if it
123 is newer than
124 .Ar file
125 on the local host.
126 (HTTP only)
127 .It Fl l
128 If the target is a file-scheme URL, make a symbolic link to the target
129 rather than trying to copy it.
130 .It Fl M
131 .It Fl m
132 Mirror mode: if the file already exists locally and has the same size
133 and modification time as the remote file, it will not be fetched.
134 Note that the
135 .Fl m
136 and
137 .Fl r
138 flags are mutually exclusive.
139 .It Fl N Ar file
140 Use
141 .Ar file
142 instead of
143 .Pa ~/.netrc
144 to look up login names and passwords for FTP sites.
145 See
146 .Xr ftp 1
147 for a description of the file format.
148 This feature is experimental.
149 .It Fl n
150 Do not preserve the modification time of the transferred file.
151 .It Fl o Ar file
152 Set the output file name to
153 .Ar file .
154 By default, a ``pathname'' is extracted from the specified URI, and
155 its basename is used as the name of the output file.
156 A
157 .Ar file
158 argument of
159 .Sq Li \&-
160 indicates that results are to be directed to the standard output.
161 If the
162 .Ar file
163 argument is a directory, fetched file(s) will be placed within the
164 directory, with name(s) selected as in the default behaviour.
165 .It Fl P
166 .It Fl p
167 Use passive FTP.
168 This is useful if you are behind a firewall which blocks incoming
169 connections.
170 Try this flag if
171 .Nm
172 seems to hang when retrieving FTP URLs.
173 .It Fl q
174 Quiet mode.
175 .It Fl R
176 The output files are precious, and should not be deleted under any
177 circumstances, even if the transfer failed or was incomplete.
178 .It Fl r
179 Restart a previously interrupted transfer.
180 Note that the
181 .Fl m
182 and
183 .Fl r
184 flags are mutually exclusive.
185 .It Fl S Ar bytes
186 Require the file size reported by the server to match the specified
187 value.
188 If it does not, a message is printed and the file is not fetched.
189 If the server does not support reporting file sizes, this option is
190 ignored and the file is fetched unconditionally.
191 .It Fl s
192 Print the size in bytes of each requested file, without fetching it.
193 .It Fl T Ar seconds
194 Set timeout value to
195 .Ar seconds .
196 Overrides the environment variables
197 .Ev FTP_TIMEOUT
198 for FTP transfers or
199 .Ev HTTP_TIMEOUT
200 for HTTP transfers if set.
201 .It Fl U
202 When using passive FTP, allocate the port for the data connection from
203 the low (default) port range.
204 See
205 .Xr ip 4
206 for details on how to specify which port range this corresponds to.
207 .It Fl v
208 Increase verbosity level.
209 .It Fl w Ar seconds
210 When the
211 .Fl a
212 flag is specified, wait this many seconds between successive retries.
213 .El
214 .Pp
215 If
216 .Nm
217 receives a
218 .Dv SIGINFO
219 signal (see the
220 .Cm status
221 argument for
222 .Xr stty 1 ) ,
223 the current transfer rate statistics will be written to the
224 standard error output, in the same format as the standard completion
225 message.
226 .Sh ENVIRONMENT
227 .Bl -tag -width HTTP_TIMEOUT
228 .It Ev FTP_TIMEOUT
229 Maximum time, in seconds, to wait before aborting an FTP connection.
230 .It Ev HTTP_TIMEOUT
231 Maximum time, in seconds, to wait before aborting an HTTP connection.
232 .El
233 .Pp
234 See
235 .Xr fetch 3
236 for a description of additional environment variables, including
237 .Ev FETCH_BIND_ADDRESS ,
238 .Ev FTP_LOGIN ,
239 .Ev FTP_PASSIVE_MODE ,
240 .Ev FTP_PASSWORD ,
241 .Ev FTP_PROXY ,
242 .Ev ftp_proxy ,
243 .Ev HTTP_AUTH ,
244 .Ev HTTP_PROXY ,
245 .Ev http_proxy ,
246 .Ev HTTP_PROXY_AUTH ,
247 .Ev HTTP_REFERER ,
248 .Ev HTTP_USER_AGENT ,
249 .Ev NETRC ,
250 .Ev NO_PROXY and
251 .Ev no_proxy .
252 .Sh EXIT STATUS
253 The
254 .Nm
255 command returns zero on success, or one on failure.
256 If multiple URLs are listed on the command line,
257 .Nm
258 will attempt to retrieve each one of them in turn, and will return
259 zero only if they were all successfully retrieved.
260 .Pp
261 If the
262 .Fl i
263 argument is used and the remote file is not newer than the
264 specified file then the command will still return success,
265 although no file is transferred.
266 .Sh SEE ALSO
267 .Xr fetch 3
268 .Sh HISTORY
269 The
270 .Nm
271 command appeared in
272 .Fx 2.1.5 .
273 This implementation first appeared in
274 .Fx 4.1 .
275 .Sh AUTHORS
276 .An -nosplit
277 The original implementation of
278 .Nm
279 was done by
280 .An Jean-Marc Zucconi Aq jmz@FreeBSD.org .
281 It was extensively re-worked for
282 .Fx 2.2
283 by
284 .An Garrett Wollman Aq wollman@FreeBSD.org ,
285 and later completely rewritten to use the
286 .Xr fetch 3
287 library by
288 .An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
289 .Sh NOTES
290 The
291 .Fl b
292 and
293 .Fl t
294 options are no longer supported and will generate warnings.
295 They were workarounds for bugs in other OSes which this implementation
296 does not trigger.
297 .Pp
298 One cannot both use the
299 .Fl h ,
300 .Fl c
301 and
302 .Fl f
303 options and specify URLs on the command line.