11130b656SJordan K. Hubbard.\" $FreeBSD$ 27fefc698SJordan K. Hubbard.Dd July 2, 1996 37fefc698SJordan K. Hubbard.Dt FETCH 1 476dafb89SGarrett Wollman.Os FreeBSD 3.0 57fefc698SJordan K. Hubbard.Sh NAME 67fefc698SJordan K. Hubbard.Nm fetch 77fefc698SJordan K. Hubbard.Nd retrieve a file by Uniform Resource Locator 87fefc698SJordan K. Hubbard.Sh SYNOPSIS 97fefc698SJordan K. Hubbard.Nm fetch 102494e810SGarrett Wollman.Op Fl MPamnpqr 117fefc698SJordan K. Hubbard.Op Fl o Ar file 127fefc698SJordan K. Hubbard.Ar URL 1376dafb89SGarrett Wollman.Op Ar ... 147fefc698SJordan K. Hubbard.Nm fetch 1578be3199SGarrett Wollman.Op Fl MPRmnpqr 167fefc698SJordan K. Hubbard.Op Fl o Ar file 177fefc698SJordan K. Hubbard.Op Fl c Ar dir 187fefc698SJordan K. Hubbard.Fl f Ar file 197fefc698SJordan K. Hubbard.Fl h Ar host 207fefc698SJordan K. Hubbard.Sh DESCRIPTION 217fefc698SJordan K. Hubbard.Nm fetch 227fefc698SJordan K. Hubbardallows a user to transfer files from a remote network site using 237fefc698SJordan K. Hubbardeither the 2476dafb89SGarrett Wollman.Tn FTP 257fefc698SJordan K. Hubbardor the 2676dafb89SGarrett Wollman.Tn HTTP 277fefc698SJordan K. Hubbardprotocol. In the first form of the command, the 287fefc698SJordan K. Hubbard.Ar URL 297fefc698SJordan K. Hubbardmay be of the form 3078be3199SGarrett Wollman.Li http://site.domain/path/to/the/file 317fefc698SJordan K. Hubbardor 3278be3199SGarrett Wollman.Li ftp://site.domain/path/to/the/file. 3378be3199SGarrett WollmanTo denote a local filename to be copied or linked to (see the 34fc6fcbf9SJordan K. Hubbard.Fl l 3578be3199SGarrett Wollmanflag below), the 36fc6fcbf9SJordan K. Hubbard.Em file:/path/to/the/file 37fc6fcbf9SJordan K. HubbardURL form is used. 3878be3199SGarrett Wollman.Pp 397fefc698SJordan K. HubbardThe second form of the command can be used to get a file using the 4078be3199SGarrett Wollman.Tn FTP 417fefc698SJordan K. Hubbardprotocol, specifying the file name and the remote host with the 427fefc698SJordan K. Hubbard.Fl h 437fefc698SJordan K. Hubbardand the 447fefc698SJordan K. Hubbard.Fl f 457fefc698SJordan K. Hubbardflags. 467fefc698SJordan K. Hubbard.Pp 477fefc698SJordan K. HubbardThe following options are available: 4876dafb89SGarrett Wollman.Bl -tag -width Fl 492494e810SGarrett Wollman.It Fl a 502494e810SGarrett WollmanAutomatically retry the transfer upon soft failures. 5178be3199SGarrett Wollman.It Fl c Ar dir 5278be3199SGarrett WollmanThe file to retrieve is in directory 5378be3199SGarrett Wollman.Ar dir 5478be3199SGarrett Wollmanon the remote host. 5578be3199SGarrett Wollman.It Fl f Ar file 5678be3199SGarrett WollmanThe file to retrieve is named 5778be3199SGarrett Wollman.Ar file 5878be3199SGarrett Wollmanon the remote host. 5978be3199SGarrett Wollman.It Fl h Ar host 6078be3199SGarrett WollmanThe file to retrieve is located on the host 6178be3199SGarrett Wollman.Ar host . 6278be3199SGarrett Wollman.It Fl l 6378be3199SGarrett WollmanIf target is a 6478be3199SGarrett Wollman.Ar file:/ 6578be3199SGarrett Wollmanstyle of URL, make a link to the target rather than trying 6678be3199SGarrett Wollmanto copy it. 677fefc698SJordan K. Hubbard.It Fl M 687fefc698SJordan K. Hubbard.It Fl m 697fefc698SJordan K. HubbardMirror mode: Set the modification time of the file so that it is 707fefc698SJordan K. Hubbardidentical to the modification time of the file at the remote host. 717fefc698SJordan K. HubbardIf the file already exists on the local host and is identical (as 727fefc698SJordan K. Hubbardgauged by size and modification time), no transfer is done. 736b5c2db2SJordan K. Hubbard.It Fl n 746b5c2db2SJordan K. HubbardDon't preserve the modtime of the transfered file, use the current time. 7578be3199SGarrett Wollman.It Fl o Ar file 7678be3199SGarrett WollmanSet the output file name to 7778be3199SGarrett Wollman.Ar file . 7878be3199SGarrett WollmanBy default, a ``pathname'' is extracted from the specified URI, and 7978be3199SGarrett Wollmanits basename is used as the name of the output file. A 8078be3199SGarrett Wollman.Ar file 8178be3199SGarrett Wollmanargument of 8278be3199SGarrett Wollman.Sq Li \&- 8378be3199SGarrett Wollmanindicates that results are to be directed to the standard output. 847fefc698SJordan K. Hubbard.It Fl P 857fefc698SJordan K. Hubbard.It Fl p 8678be3199SGarrett WollmanUse the passive mode of the 8778be3199SGarrett Wollman.Tn FTP 8878be3199SGarrett Wollmanprotocol. This is useful for crossing certain sorts of firewalls. 8978be3199SGarrett Wollman.It Fl q 9078be3199SGarrett WollmanQuiet mode. Do not report transfer progress on the terminal. 9178be3199SGarrett Wollman.It Fl R 9278be3199SGarrett WollmanThe filenames specified are ``precious'', and should not be deleted 9378be3199SGarrett Wollmanunder any circumstances, even if the transfer failed or was incomplete. 9478be3199SGarrett Wollman.It Fl r 9578be3199SGarrett WollmanRestart a previously interrupted transfer. 96fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds 97fc6fcbf9SJordan K. HubbardSet timeout value to 98fc6fcbf9SJordan K. Hubbard.Ar seconds. 99a43a248cSPeter WemmOverrides the environment variables 100fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT 101a43a248cSPeter Wemmfor ftp transfers or 102a43a248cSPeter Wemm.Ev HTTP_TIMEOUT 103a43a248cSPeter Wemmfor http transfers if set. 1047ae26f14SJordan K. Hubbard.It Fl v 10578be3199SGarrett WollmanIncrease verbosity. More 10678be3199SGarrett Wollman.Fl v Ns \&'s 10778be3199SGarrett Wollmanresult in more information. 1087fefc698SJordan K. Hubbard.El 10978be3199SGarrett Wollman.Pp 11078be3199SGarrett WollmanMany options are also controlled solely by the environment (this is a 11178be3199SGarrett Wollmanbug). 11278be3199SGarrett Wollman.Sh PROXY SERVERS 11378be3199SGarrett WollmanMany sites use application gateways (``proxy servers'') in their 11478be3199SGarrett Wollmanfirewalls in order to allow communication across the firewall using a 11578be3199SGarrett Wollmantrusted protocol. The 11678be3199SGarrett Wollman.Nm fetch 11778be3199SGarrett Wollmanprogram can use both the 11878be3199SGarrett Wollman.Tn FTP 11978be3199SGarrett Wollmanand the 12078be3199SGarrett Wollman.Tn HTTP 12178be3199SGarrett Wollmanprotocol with a proxy server. 12278be3199SGarrett Wollman.Tn FTP 12378be3199SGarrett Wollmanproxy servers can only relay 12478be3199SGarrett Wollman.Tn FTP 12578be3199SGarrett Wollmanrequests; 12678be3199SGarrett Wollman.Tn HTTP 12778be3199SGarrett Wollmanproxy servers can relay both 12878be3199SGarrett Wollman.Tn FTP 12978be3199SGarrett Wollmanand 13078be3199SGarrett Wollman.Tn HTTP 13178be3199SGarrett Wollmanrequests. 13278be3199SGarrett WollmanA proxy server can be configured by defining an environment variable 13378be3199SGarrett Wollmannamed 13478be3199SGarrett Wollman.Dq Va PROTO Ns Ev _PROXY , 13578be3199SGarrett Wollmanwhere 13678be3199SGarrett Wollman.Va PROTO 13778be3199SGarrett Wollmanis the name of the protocol in upper case. The value of the 13878be3199SGarrett Wollmanenvironment variable specifies a hostname, optionally followed by a 13978be3199SGarrett Wollmancolon and a port number. 14078be3199SGarrett Wollman.Pp 14178be3199SGarrett WollmanThe 14278be3199SGarrett Wollman.Tn FTP 14378be3199SGarrett Wollmanproxy client specifies 14478be3199SGarrett Wollman.Dq anonymous 14578be3199SGarrett Wollmanas its user name, and passes the remote user name and host as the 14678be3199SGarrett Wollman.Tn FTP 14778be3199SGarrett Wollmansession's password, in the form 14876dafb89SGarrett Wollman.Dq Va remoteuser Ns Li \&@ Ns Va remotehost . 14978be3199SGarrett WollmanThe 15078be3199SGarrett Wollman.Tn HTTP 15178be3199SGarrett Wollmanproxy client simply passes the originally-requested URI to the remote 15278be3199SGarrett Wollmanserver in an 15378be3199SGarrett Wollman.Tn HTTP 15478be3199SGarrett Wollman.Dq Li GET 15578be3199SGarrett Wollmanrequest. HTTP proxy authentication is not yet implemented. 15678be3199SGarrett WollmanWhen multiple proxy protcols are configured, 15778be3199SGarrett Wollman.Nm 15878be3199SGarrett Wollmanwill prefer 15978be3199SGarrett Wollman.Tn HTTP . 16076dafb89SGarrett Wollman.Sh HTTP AUTHENTICATION 16176dafb89SGarrett WollmanThe 16276dafb89SGarrett Wollman.Tn HTTP 16376dafb89SGarrett Wollmanprotocol includes support for various methods of authentication. 16476dafb89SGarrett WollmanCurrently, the 16576dafb89SGarrett Wollman.Dq basic 16676dafb89SGarrett Wollmanmethod, which provides no security from packet-sniffing or 16776dafb89SGarrett Wollmanman-in-the-middle attacks, is the only method supported in 16876dafb89SGarrett Wollman.Nm fetch . 16976dafb89SGarrett WollmanAuthentication is enabled by the 17076dafb89SGarrett Wollman.Ev HTTP_AUTH 17176dafb89SGarrett Wollmanand 17276dafb89SGarrett Wollman.Ev HTTP_PROXY_AUTH 17376dafb89SGarrett Wollmanenvironment variables. Both variables have the same format, which 17476dafb89SGarrett Wollmanconsists of space-separated list of parameter settings, where each 17576dafb89SGarrett Wollmansetting consists of a colon-separated list of parameters. The first 17676dafb89SGarrett Wollmantwo parameters are always the (case-insensitive) authentication scheme 17776dafb89SGarrett Wollmanname and the realm in which authentication is to be performed. If the 17876dafb89SGarrett Wollmanrealm is specified as 17976dafb89SGarrett Wollman.Sq Li \&* , 18076dafb89SGarrett Wollmanthen it will match all realms not specified otherwise. 18176dafb89SGarrett Wollman.Pp 18276dafb89SGarrett WollmanFor the 18376dafb89SGarrett Wollman.Li basic 18476dafb89SGarrett Wollmanauthentication scheme uses two additional optional parameters; the 18576dafb89SGarrett Wollmanfirst is a user name, and the second is the password associated with 18676dafb89SGarrett Wollmanit. If either the password or both parameters are not specified in 18776dafb89SGarrett Wollmanthe environment, and the standard input of 18876dafb89SGarrett Wollman.Nm 18976dafb89SGarrett Wollmanis connected to a terminal, then 19076dafb89SGarrett Wollman.Nm 19176dafb89SGarrett Wollmanwill prompt the user to enter the missing parameters. Thus, if the 19276dafb89SGarrett Wollmanuser is known as 19376dafb89SGarrett Wollman.Dq Li jane 19476dafb89SGarrett Wollmanin the 19576dafb89SGarrett Wollman.Dq Li WallyWorld 19676dafb89SGarrett Wollmanrealm, and has a password of 19776dafb89SGarrett Wollman.Dq Li QghiLx79 19876dafb89SGarrett Wollmanthere, then she might set her 19976dafb89SGarrett Wollman.Ev HTTP_AUTH 20076dafb89SGarrett Wollmanvariable to: 20176dafb89SGarrett Wollman.Bl -enum -offset indent 20276dafb89SGarrett Wollman.It 20376dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane:QghiLx79 20476dafb89SGarrett Wollman.It 20576dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane , 20676dafb89SGarrett Wollmanor 20776dafb89SGarrett Wollman.It 20876dafb89SGarrett Wollman.Dq Li basic:WallyWorld 20976dafb89SGarrett Wollman.El 21076dafb89SGarrett Wollman.Pp 21176dafb89SGarrett Wollmanand 21276dafb89SGarrett Wollman.Nm 21376dafb89SGarrett Wollmanwill prompt for the missing information if it is required. She might 21476dafb89SGarrett Wollmanalso specify a realm of 21576dafb89SGarrett Wollman.Dq Li \&* 21676dafb89SGarrett Wollmaninstead of 21776dafb89SGarrett Wollman.Dq Li WallyWorld 21876dafb89SGarrett Wollmanto indicate that the parameters can be applied to any realm. (This is 21976dafb89SGarrett Wollmanmost commonly used in a construction such as 22076dafb89SGarrett Wollman.Dq Li basic:* , 22176dafb89SGarrett Wollmanwhich indicates to 22276dafb89SGarrett Wollman.Nm 22376dafb89SGarrett Wollmanthat it may offer to do 22476dafb89SGarrett Wollman.Li basic 22576dafb89SGarrett Wollmanauthentication for any realm. 22676dafb89SGarrett Wollman.Sh ERRORS 22776dafb89SGarrett WollmanThe 22876dafb89SGarrett Wollman.Nm 22976dafb89SGarrett Wollmancommand returns zero on success, or a non-zero value from 23076dafb89SGarrett Wollman.Aq Pa sysexits.h 23176dafb89SGarrett Wollmanon failure. If multiple URIs are given for retrieval, 23276dafb89SGarrett Wollman.Nm 23376dafb89SGarrett Wollmanwill attempt all of them and return zero only if all succeeded 23476dafb89SGarrett Wollman(otherwise it will return the error from the last failure). 2357fefc698SJordan K. Hubbard.Sh ENVIRONMENT 23678be3199SGarrett Wollman.Bl -tag -width FTP_PASSIVE_MODE -offset indent 23778be3199SGarrett Wollman.It Ev FTP_TIMEOUT 23878be3199SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 23978be3199SGarrett Wollman.Tn FTP 24078be3199SGarrett Wollmanconnection. 24178be3199SGarrett Wollman.It Ev FTP_LOGIN 24278be3199SGarrett Wollmanthe login name used for 24378be3199SGarrett Wollman.Tn FTP 24478be3199SGarrett Wollmantransfers (default 24578be3199SGarrett Wollman.Dq Li anonymous ) 24676dafb89SGarrett Wollman.It Ev FTP_PASSIVE_MODE 24776dafb89SGarrett Wollmanforce the use of passive mode FTP 24878be3199SGarrett Wollman.It Ev FTP_PASSWORD 24978be3199SGarrett Wollmanthe password used for 25078be3199SGarrett Wollman.Tn FTP 25178be3199SGarrett Wollmantransfers (default 25278be3199SGarrett Wollman.Dq Va yourname Ns Li \&@ Ns Va yourhost ) 25378be3199SGarrett Wollman.It Ev FTP_PROXY 25478be3199SGarrett Wollmanthe address of a proxy server which understands 25578be3199SGarrett Wollman.Tn FTP 25676dafb89SGarrett Wollman.It Ev HTTP_AUTH 25776dafb89SGarrett Wollmandefines authentication parameters for 25876dafb89SGarrett Wollman.Tn HTTP 25976dafb89SGarrett Wollman.It Ev HTTP_PROXY 26076dafb89SGarrett Wollmanthe address of a proxy server which understands 26176dafb89SGarrett Wollman.Tn HTTP 26276dafb89SGarrett Wollman.It Ev HTTP_PROXY_AUTH 26376dafb89SGarrett Wollmandefines authentication parameters for 26476dafb89SGarrett Wollman.Tn HTTP 26576dafb89SGarrett Wollmanproxy servers 26676dafb89SGarrett Wollman.It Ev HTTP_TIMEOUT 26776dafb89SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 26876dafb89SGarrett Wollman.Tn HTTP 26976dafb89SGarrett Wollmanconnection. 2707fefc698SJordan K. Hubbard.Sh SEE ALSO 271da1ff3cbSWolfram Schneider.Xr ftp 1 , 272da1ff3cbSWolfram Schneider.Xr tftp 1 2737fefc698SJordan K. Hubbard.Sh HISTORY 2747fefc698SJordan K. HubbardThe 2757fefc698SJordan K. Hubbard.Nm fetch 27685cf659aSMike Pritchardcommand appeared in 27785cf659aSMike Pritchard.Fx 2.1.5 . 27878be3199SGarrett Wollman.Sh AUTHORS 27978be3199SGarrett WollmanThe original implementation of 28078be3199SGarrett Wollman.Nm 28178be3199SGarrett Wollmanwas done by Jean-Marc Zucconi. It was extensively re-worked for 28278be3199SGarrett Wollman.Fx 3.0 28378be3199SGarrett Wollmanby Garrett Wollman. 2842494e810SGarrett Wollman.Sh BUGS 2852494e810SGarrett WollmanThere are too many environment variables and command-line options. 2862494e810SGarrett Wollman.Pp 2872494e810SGarrett WollmanThe 2882494e810SGarrett Wollman.Fl a 2892494e810SGarrett Wollmanoption is only implemented for certain kinds of 2902494e810SGarrett Wollman.Tn HTTP 2912494e810SGarrett Wollmanfailures, and no 2922494e810SGarrett Wollman.Tn FTP 2932494e810SGarrett Wollmanfailures. 2942494e810SGarrett Wollman.Pp 29576dafb89SGarrett WollmanOnly the 29676dafb89SGarrett Wollman.Dq basic 29776dafb89SGarrett Wollmanauthentication mode is implemented for 29876dafb89SGarrett Wollman.Tn HTTP . 29976dafb89SGarrett WollmanThis should be replaced by digest authentication. 300