10c8cc99eSGarrett Wollman.\" $Id: fetch.1,v 1.17 1997/03/05 18:57:15 fenner Exp $ 27fefc698SJordan K. Hubbard.Dd July 2, 1996 37fefc698SJordan K. Hubbard.Dt FETCH 1 4bc5d5816SWolfram Schneider.Os FreeBSD 2.2 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 100c8cc99eSGarrett Wollman.Op Fl MPabmnpqr 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. 510c8cc99eSGarrett Wollman.It Fl b 520c8cc99eSGarrett WollmanWork around a bug in some 530c8cc99eSGarrett Wollman.Tn HTTP 540c8cc99eSGarrett Wollmanservers which fail to correctly implement the 550c8cc99eSGarrett Wollman.Tn TCP 560c8cc99eSGarrett Wollmanprotocol. 5778be3199SGarrett Wollman.It Fl c Ar dir 5878be3199SGarrett WollmanThe file to retrieve is in directory 5978be3199SGarrett Wollman.Ar dir 6078be3199SGarrett Wollmanon the remote host. 6178be3199SGarrett Wollman.It Fl f Ar file 6278be3199SGarrett WollmanThe file to retrieve is named 6378be3199SGarrett Wollman.Ar file 6478be3199SGarrett Wollmanon the remote host. 6578be3199SGarrett Wollman.It Fl h Ar host 6678be3199SGarrett WollmanThe file to retrieve is located on the host 6778be3199SGarrett Wollman.Ar host . 6878be3199SGarrett Wollman.It Fl l 6978be3199SGarrett WollmanIf target is a 7078be3199SGarrett Wollman.Ar file:/ 7178be3199SGarrett Wollmanstyle of URL, make a link to the target rather than trying 7278be3199SGarrett Wollmanto copy it. 737fefc698SJordan K. Hubbard.It Fl M 747fefc698SJordan K. Hubbard.It Fl m 757fefc698SJordan K. HubbardMirror mode: Set the modification time of the file so that it is 767fefc698SJordan K. Hubbardidentical to the modification time of the file at the remote host. 777fefc698SJordan K. HubbardIf the file already exists on the local host and is identical (as 787fefc698SJordan K. Hubbardgauged by size and modification time), no transfer is done. 796b5c2db2SJordan K. Hubbard.It Fl n 806b5c2db2SJordan K. HubbardDon't preserve the modtime of the transfered file, use the current time. 8178be3199SGarrett Wollman.It Fl o Ar file 8278be3199SGarrett WollmanSet the output file name to 8378be3199SGarrett Wollman.Ar file . 8478be3199SGarrett WollmanBy default, a ``pathname'' is extracted from the specified URI, and 8578be3199SGarrett Wollmanits basename is used as the name of the output file. A 8678be3199SGarrett Wollman.Ar file 8778be3199SGarrett Wollmanargument of 8878be3199SGarrett Wollman.Sq Li \&- 8978be3199SGarrett Wollmanindicates that results are to be directed to the standard output. 907fefc698SJordan K. Hubbard.It Fl P 917fefc698SJordan K. Hubbard.It Fl p 9278be3199SGarrett WollmanUse the passive mode of the 9378be3199SGarrett Wollman.Tn FTP 9478be3199SGarrett Wollmanprotocol. This is useful for crossing certain sorts of firewalls. 9578be3199SGarrett Wollman.It Fl q 9678be3199SGarrett WollmanQuiet mode. Do not report transfer progress on the terminal. 9778be3199SGarrett Wollman.It Fl R 9878be3199SGarrett WollmanThe filenames specified are ``precious'', and should not be deleted 9978be3199SGarrett Wollmanunder any circumstances, even if the transfer failed or was incomplete. 10078be3199SGarrett Wollman.It Fl r 10178be3199SGarrett WollmanRestart a previously interrupted transfer. 102fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds 103fc6fcbf9SJordan K. HubbardSet timeout value to 104fc6fcbf9SJordan K. Hubbard.Ar seconds. 105a43a248cSPeter WemmOverrides the environment variables 106fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT 107a43a248cSPeter Wemmfor ftp transfers or 108a43a248cSPeter Wemm.Ev HTTP_TIMEOUT 109a43a248cSPeter Wemmfor http transfers if set. 1107ae26f14SJordan K. Hubbard.It Fl v 11178be3199SGarrett WollmanIncrease verbosity. More 11278be3199SGarrett Wollman.Fl v Ns \&'s 11378be3199SGarrett Wollmanresult in more information. 1147fefc698SJordan K. Hubbard.El 11578be3199SGarrett Wollman.Pp 11678be3199SGarrett WollmanMany options are also controlled solely by the environment (this is a 11778be3199SGarrett Wollmanbug). 11878be3199SGarrett Wollman.Sh PROXY SERVERS 11978be3199SGarrett WollmanMany sites use application gateways (``proxy servers'') in their 12078be3199SGarrett Wollmanfirewalls in order to allow communication across the firewall using a 12178be3199SGarrett Wollmantrusted protocol. The 12278be3199SGarrett Wollman.Nm fetch 12378be3199SGarrett Wollmanprogram can use both the 12478be3199SGarrett Wollman.Tn FTP 12578be3199SGarrett Wollmanand the 12678be3199SGarrett Wollman.Tn HTTP 12778be3199SGarrett Wollmanprotocol with a proxy server. 12878be3199SGarrett Wollman.Tn FTP 12978be3199SGarrett Wollmanproxy servers can only relay 13078be3199SGarrett Wollman.Tn FTP 13178be3199SGarrett Wollmanrequests; 13278be3199SGarrett Wollman.Tn HTTP 13378be3199SGarrett Wollmanproxy servers can relay both 13478be3199SGarrett Wollman.Tn FTP 13578be3199SGarrett Wollmanand 13678be3199SGarrett Wollman.Tn HTTP 13778be3199SGarrett Wollmanrequests. 13878be3199SGarrett WollmanA proxy server can be configured by defining an environment variable 13978be3199SGarrett Wollmannamed 14078be3199SGarrett Wollman.Dq Va PROTO Ns Ev _PROXY , 14178be3199SGarrett Wollmanwhere 14278be3199SGarrett Wollman.Va PROTO 14378be3199SGarrett Wollmanis the name of the protocol in upper case. The value of the 14478be3199SGarrett Wollmanenvironment variable specifies a hostname, optionally followed by a 14578be3199SGarrett Wollmancolon and a port number. 14678be3199SGarrett Wollman.Pp 14778be3199SGarrett WollmanThe 14878be3199SGarrett Wollman.Tn FTP 1498a2f8e39SBill Fennerproxy client passes the remote username, host and port as the 15078be3199SGarrett Wollman.Tn FTP 1518a2f8e39SBill Fennersession's username, in the form 1528a2f8e39SBill Fenner.Do Va remoteuser Ns Li \&@ Ns Va remotehost 1538a2f8e39SBill Fenner.Op Li \^@ Ns Va port 1548a2f8e39SBill Fenner.Dc . 15578be3199SGarrett WollmanThe 15678be3199SGarrett Wollman.Tn HTTP 15778be3199SGarrett Wollmanproxy client simply passes the originally-requested URI to the remote 15878be3199SGarrett Wollmanserver in an 15978be3199SGarrett Wollman.Tn HTTP 16078be3199SGarrett Wollman.Dq Li GET 16178be3199SGarrett Wollmanrequest. HTTP proxy authentication is not yet implemented. 16276dafb89SGarrett Wollman.Sh HTTP AUTHENTICATION 16376dafb89SGarrett WollmanThe 16476dafb89SGarrett Wollman.Tn HTTP 16576dafb89SGarrett Wollmanprotocol includes support for various methods of authentication. 16676dafb89SGarrett WollmanCurrently, the 16776dafb89SGarrett Wollman.Dq basic 16876dafb89SGarrett Wollmanmethod, which provides no security from packet-sniffing or 16976dafb89SGarrett Wollmanman-in-the-middle attacks, is the only method supported in 17076dafb89SGarrett Wollman.Nm fetch . 17176dafb89SGarrett WollmanAuthentication is enabled by the 17276dafb89SGarrett Wollman.Ev HTTP_AUTH 17376dafb89SGarrett Wollmanand 17476dafb89SGarrett Wollman.Ev HTTP_PROXY_AUTH 17576dafb89SGarrett Wollmanenvironment variables. Both variables have the same format, which 17676dafb89SGarrett Wollmanconsists of space-separated list of parameter settings, where each 17776dafb89SGarrett Wollmansetting consists of a colon-separated list of parameters. The first 17876dafb89SGarrett Wollmantwo parameters are always the (case-insensitive) authentication scheme 17976dafb89SGarrett Wollmanname and the realm in which authentication is to be performed. If the 18076dafb89SGarrett Wollmanrealm is specified as 18176dafb89SGarrett Wollman.Sq Li \&* , 18276dafb89SGarrett Wollmanthen it will match all realms not specified otherwise. 18376dafb89SGarrett Wollman.Pp 18476dafb89SGarrett WollmanFor the 18576dafb89SGarrett Wollman.Li basic 18676dafb89SGarrett Wollmanauthentication scheme uses two additional optional parameters; the 18776dafb89SGarrett Wollmanfirst is a user name, and the second is the password associated with 18876dafb89SGarrett Wollmanit. If either the password or both parameters are not specified in 18976dafb89SGarrett Wollmanthe environment, and the standard input of 19076dafb89SGarrett Wollman.Nm 19176dafb89SGarrett Wollmanis connected to a terminal, then 19276dafb89SGarrett Wollman.Nm 19376dafb89SGarrett Wollmanwill prompt the user to enter the missing parameters. Thus, if the 19476dafb89SGarrett Wollmanuser is known as 19576dafb89SGarrett Wollman.Dq Li jane 19676dafb89SGarrett Wollmanin the 19776dafb89SGarrett Wollman.Dq Li WallyWorld 19876dafb89SGarrett Wollmanrealm, and has a password of 19976dafb89SGarrett Wollman.Dq Li QghiLx79 20076dafb89SGarrett Wollmanthere, then she might set her 20176dafb89SGarrett Wollman.Ev HTTP_AUTH 20276dafb89SGarrett Wollmanvariable to: 20376dafb89SGarrett Wollman.Bl -enum -offset indent 20476dafb89SGarrett Wollman.It 20576dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane:QghiLx79 20676dafb89SGarrett Wollman.It 20776dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane , 20876dafb89SGarrett Wollmanor 20976dafb89SGarrett Wollman.It 21076dafb89SGarrett Wollman.Dq Li basic:WallyWorld 21176dafb89SGarrett Wollman.El 21276dafb89SGarrett Wollman.Pp 21376dafb89SGarrett Wollmanand 21476dafb89SGarrett Wollman.Nm 21576dafb89SGarrett Wollmanwill prompt for the missing information if it is required. She might 21676dafb89SGarrett Wollmanalso specify a realm of 21776dafb89SGarrett Wollman.Dq Li \&* 21876dafb89SGarrett Wollmaninstead of 21976dafb89SGarrett Wollman.Dq Li WallyWorld 22076dafb89SGarrett Wollmanto indicate that the parameters can be applied to any realm. (This is 22176dafb89SGarrett Wollmanmost commonly used in a construction such as 22276dafb89SGarrett Wollman.Dq Li basic:* , 22376dafb89SGarrett Wollmanwhich indicates to 22476dafb89SGarrett Wollman.Nm 22576dafb89SGarrett Wollmanthat it may offer to do 22676dafb89SGarrett Wollman.Li basic 22776dafb89SGarrett Wollmanauthentication for any realm. 22876dafb89SGarrett Wollman.Sh ERRORS 22976dafb89SGarrett WollmanThe 23076dafb89SGarrett Wollman.Nm 23176dafb89SGarrett Wollmancommand returns zero on success, or a non-zero value from 23276dafb89SGarrett Wollman.Aq Pa sysexits.h 23376dafb89SGarrett Wollmanon failure. If multiple URIs are given for retrieval, 23476dafb89SGarrett Wollman.Nm 23576dafb89SGarrett Wollmanwill attempt all of them and return zero only if all succeeded 23676dafb89SGarrett Wollman(otherwise it will return the error from the last failure). 2377fefc698SJordan K. Hubbard.Sh ENVIRONMENT 23878be3199SGarrett Wollman.Bl -tag -width FTP_PASSIVE_MODE -offset indent 23978be3199SGarrett Wollman.It Ev FTP_TIMEOUT 24078be3199SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 24178be3199SGarrett Wollman.Tn FTP 24278be3199SGarrett Wollmanconnection. 24378be3199SGarrett Wollman.It Ev FTP_LOGIN 24478be3199SGarrett Wollmanthe login name used for 24578be3199SGarrett Wollman.Tn FTP 24678be3199SGarrett Wollmantransfers (default 24778be3199SGarrett Wollman.Dq Li anonymous ) 24876dafb89SGarrett Wollman.It Ev FTP_PASSIVE_MODE 24976dafb89SGarrett Wollmanforce the use of passive mode FTP 25078be3199SGarrett Wollman.It Ev FTP_PASSWORD 25178be3199SGarrett Wollmanthe password used for 25278be3199SGarrett Wollman.Tn FTP 25378be3199SGarrett Wollmantransfers (default 25478be3199SGarrett Wollman.Dq Va yourname Ns Li \&@ Ns Va yourhost ) 25578be3199SGarrett Wollman.It Ev FTP_PROXY 2568a2f8e39SBill Fennerthe address (in the form 2578a2f8e39SBill Fenner.Do Va hostname Ns 2588a2f8e39SBill Fenner.Op Li : Ns Va port 2598a2f8e39SBill Fenner.Dc ) 2608a2f8e39SBill Fennerof a proxy server which understands 26178be3199SGarrett Wollman.Tn FTP 26276dafb89SGarrett Wollman.It Ev HTTP_AUTH 26376dafb89SGarrett Wollmandefines authentication parameters for 26476dafb89SGarrett Wollman.Tn HTTP 26576dafb89SGarrett Wollman.It Ev HTTP_PROXY 2668a2f8e39SBill Fennerthe address (in the form 2678a2f8e39SBill Fenner.Do Va hostname Ns 2688a2f8e39SBill Fenner.Op Li : Ns Va port 2698a2f8e39SBill Fenner.Dc ) 2708a2f8e39SBill Fennerof a proxy server which understands 27176dafb89SGarrett Wollman.Tn HTTP 27276dafb89SGarrett Wollman.It Ev HTTP_PROXY_AUTH 27376dafb89SGarrett Wollmandefines authentication parameters for 27476dafb89SGarrett Wollman.Tn HTTP 27576dafb89SGarrett Wollmanproxy servers 27676dafb89SGarrett Wollman.It Ev HTTP_TIMEOUT 27776dafb89SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 27876dafb89SGarrett Wollman.Tn HTTP 27976dafb89SGarrett Wollmanconnection. 2807fefc698SJordan K. Hubbard.Sh SEE ALSO 281da1ff3cbSWolfram Schneider.Xr ftp 1 , 282da1ff3cbSWolfram Schneider.Xr tftp 1 2837fefc698SJordan K. Hubbard.Sh HISTORY 2847fefc698SJordan K. HubbardThe 2857fefc698SJordan K. Hubbard.Nm fetch 28685cf659aSMike Pritchardcommand appeared in 28785cf659aSMike Pritchard.Fx 2.1.5 . 28878be3199SGarrett Wollman.Sh AUTHORS 28978be3199SGarrett WollmanThe original implementation of 29078be3199SGarrett Wollman.Nm 29178be3199SGarrett Wollmanwas done by Jean-Marc Zucconi. It was extensively re-worked for 292bc5d5816SWolfram Schneider.Fx 2.2 29378be3199SGarrett Wollmanby Garrett Wollman. 2942494e810SGarrett Wollman.Sh BUGS 2952494e810SGarrett WollmanThere are too many environment variables and command-line options. 2962494e810SGarrett Wollman.Pp 2972494e810SGarrett WollmanThe 2982494e810SGarrett Wollman.Fl a 2992494e810SGarrett Wollmanoption is only implemented for certain kinds of 3002494e810SGarrett Wollman.Tn HTTP 3012494e810SGarrett Wollmanfailures, and no 3022494e810SGarrett Wollman.Tn FTP 3032494e810SGarrett Wollmanfailures. 3042494e810SGarrett Wollman.Pp 30576dafb89SGarrett WollmanOnly the 30676dafb89SGarrett Wollman.Dq basic 30776dafb89SGarrett Wollmanauthentication mode is implemented for 30876dafb89SGarrett Wollman.Tn HTTP . 30976dafb89SGarrett WollmanThis should be replaced by digest authentication. 3100c8cc99eSGarrett Wollman.Pp 3110c8cc99eSGarrett WollmanThe 3120c8cc99eSGarrett Wollman.Fl b 3130c8cc99eSGarrett Wollmanflag should not be necessary. 314