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