1306005e7SPhilippe Charnier.\" $Id: fetch.1,v 1.19 1997/08/05 20:18:37 ache 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. 102f4e4504fSAndrey A. Chernov.It Fl t 103f4e4504fSAndrey A. ChernovEnsure that the use of T/TCP is not attempted for connections. This is 104f4e4504fSAndrey A. Chernovused to workaround bugs in some remote OS stacks that give improper 105f4e4504fSAndrey A. Chernovreplies to T/TCP connections. 106fc6fcbf9SJordan K. Hubbard.It Fl T Ar seconds 107fc6fcbf9SJordan K. HubbardSet timeout value to 108fc6fcbf9SJordan K. Hubbard.Ar seconds. 109a43a248cSPeter WemmOverrides the environment variables 110fc6fcbf9SJordan K. Hubbard.Ev FTP_TIMEOUT 111a43a248cSPeter Wemmfor ftp transfers or 112a43a248cSPeter Wemm.Ev HTTP_TIMEOUT 113a43a248cSPeter Wemmfor http transfers if set. 1147ae26f14SJordan K. Hubbard.It Fl v 11578be3199SGarrett WollmanIncrease verbosity. More 11678be3199SGarrett Wollman.Fl v Ns \&'s 11778be3199SGarrett Wollmanresult in more information. 1187fefc698SJordan K. Hubbard.El 11978be3199SGarrett Wollman.Pp 12078be3199SGarrett WollmanMany options are also controlled solely by the environment (this is a 12178be3199SGarrett Wollmanbug). 12278be3199SGarrett Wollman.Sh PROXY SERVERS 12378be3199SGarrett WollmanMany sites use application gateways (``proxy servers'') in their 12478be3199SGarrett Wollmanfirewalls in order to allow communication across the firewall using a 12578be3199SGarrett Wollmantrusted protocol. The 12678be3199SGarrett Wollman.Nm fetch 12778be3199SGarrett Wollmanprogram can use both the 12878be3199SGarrett Wollman.Tn FTP 12978be3199SGarrett Wollmanand the 13078be3199SGarrett Wollman.Tn HTTP 13178be3199SGarrett Wollmanprotocol with a proxy server. 13278be3199SGarrett Wollman.Tn FTP 13378be3199SGarrett Wollmanproxy servers can only relay 13478be3199SGarrett Wollman.Tn FTP 13578be3199SGarrett Wollmanrequests; 13678be3199SGarrett Wollman.Tn HTTP 13778be3199SGarrett Wollmanproxy servers can relay both 13878be3199SGarrett Wollman.Tn FTP 13978be3199SGarrett Wollmanand 14078be3199SGarrett Wollman.Tn HTTP 14178be3199SGarrett Wollmanrequests. 14278be3199SGarrett WollmanA proxy server can be configured by defining an environment variable 14378be3199SGarrett Wollmannamed 14478be3199SGarrett Wollman.Dq Va PROTO Ns Ev _PROXY , 14578be3199SGarrett Wollmanwhere 14678be3199SGarrett Wollman.Va PROTO 14778be3199SGarrett Wollmanis the name of the protocol in upper case. The value of the 14878be3199SGarrett Wollmanenvironment variable specifies a hostname, optionally followed by a 14978be3199SGarrett Wollmancolon and a port number. 15078be3199SGarrett Wollman.Pp 15178be3199SGarrett WollmanThe 15278be3199SGarrett Wollman.Tn FTP 1538a2f8e39SBill Fennerproxy client passes the remote username, host and port as the 15478be3199SGarrett Wollman.Tn FTP 1558a2f8e39SBill Fennersession's username, in the form 1568a2f8e39SBill Fenner.Do Va remoteuser Ns Li \&@ Ns Va remotehost 1578a2f8e39SBill Fenner.Op Li \^@ Ns Va port 1588a2f8e39SBill Fenner.Dc . 15978be3199SGarrett WollmanThe 16078be3199SGarrett Wollman.Tn HTTP 16178be3199SGarrett Wollmanproxy client simply passes the originally-requested URI to the remote 16278be3199SGarrett Wollmanserver in an 16378be3199SGarrett Wollman.Tn HTTP 16478be3199SGarrett Wollman.Dq Li GET 16578be3199SGarrett Wollmanrequest. HTTP proxy authentication is not yet implemented. 16676dafb89SGarrett Wollman.Sh HTTP AUTHENTICATION 16776dafb89SGarrett WollmanThe 16876dafb89SGarrett Wollman.Tn HTTP 16976dafb89SGarrett Wollmanprotocol includes support for various methods of authentication. 17076dafb89SGarrett WollmanCurrently, the 17176dafb89SGarrett Wollman.Dq basic 17276dafb89SGarrett Wollmanmethod, which provides no security from packet-sniffing or 17376dafb89SGarrett Wollmanman-in-the-middle attacks, is the only method supported in 17476dafb89SGarrett Wollman.Nm fetch . 17576dafb89SGarrett WollmanAuthentication is enabled by the 17676dafb89SGarrett Wollman.Ev HTTP_AUTH 17776dafb89SGarrett Wollmanand 17876dafb89SGarrett Wollman.Ev HTTP_PROXY_AUTH 17976dafb89SGarrett Wollmanenvironment variables. Both variables have the same format, which 18076dafb89SGarrett Wollmanconsists of space-separated list of parameter settings, where each 18176dafb89SGarrett Wollmansetting consists of a colon-separated list of parameters. The first 18276dafb89SGarrett Wollmantwo parameters are always the (case-insensitive) authentication scheme 18376dafb89SGarrett Wollmanname and the realm in which authentication is to be performed. If the 18476dafb89SGarrett Wollmanrealm is specified as 18576dafb89SGarrett Wollman.Sq Li \&* , 18676dafb89SGarrett Wollmanthen it will match all realms not specified otherwise. 18776dafb89SGarrett Wollman.Pp 18876dafb89SGarrett WollmanFor the 18976dafb89SGarrett Wollman.Li basic 19076dafb89SGarrett Wollmanauthentication scheme uses two additional optional parameters; the 19176dafb89SGarrett Wollmanfirst is a user name, and the second is the password associated with 19276dafb89SGarrett Wollmanit. If either the password or both parameters are not specified in 19376dafb89SGarrett Wollmanthe environment, and the standard input of 19476dafb89SGarrett Wollman.Nm 19576dafb89SGarrett Wollmanis connected to a terminal, then 19676dafb89SGarrett Wollman.Nm 19776dafb89SGarrett Wollmanwill prompt the user to enter the missing parameters. Thus, if the 19876dafb89SGarrett Wollmanuser is known as 19976dafb89SGarrett Wollman.Dq Li jane 20076dafb89SGarrett Wollmanin the 20176dafb89SGarrett Wollman.Dq Li WallyWorld 20276dafb89SGarrett Wollmanrealm, and has a password of 20376dafb89SGarrett Wollman.Dq Li QghiLx79 20476dafb89SGarrett Wollmanthere, then she might set her 20576dafb89SGarrett Wollman.Ev HTTP_AUTH 20676dafb89SGarrett Wollmanvariable to: 20776dafb89SGarrett Wollman.Bl -enum -offset indent 20876dafb89SGarrett Wollman.It 20976dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane:QghiLx79 21076dafb89SGarrett Wollman.It 21176dafb89SGarrett Wollman.Dq Li basic:WallyWorld:jane , 21276dafb89SGarrett Wollmanor 21376dafb89SGarrett Wollman.It 21476dafb89SGarrett Wollman.Dq Li basic:WallyWorld 21576dafb89SGarrett Wollman.El 21676dafb89SGarrett Wollman.Pp 21776dafb89SGarrett Wollmanand 21876dafb89SGarrett Wollman.Nm 21976dafb89SGarrett Wollmanwill prompt for the missing information if it is required. She might 22076dafb89SGarrett Wollmanalso specify a realm of 22176dafb89SGarrett Wollman.Dq Li \&* 22276dafb89SGarrett Wollmaninstead of 22376dafb89SGarrett Wollman.Dq Li WallyWorld 22476dafb89SGarrett Wollmanto indicate that the parameters can be applied to any realm. (This is 22576dafb89SGarrett Wollmanmost commonly used in a construction such as 22676dafb89SGarrett Wollman.Dq Li basic:* , 22776dafb89SGarrett Wollmanwhich indicates to 22876dafb89SGarrett Wollman.Nm 22976dafb89SGarrett Wollmanthat it may offer to do 23076dafb89SGarrett Wollman.Li basic 23176dafb89SGarrett Wollmanauthentication for any realm. 23276dafb89SGarrett Wollman.Sh ERRORS 23376dafb89SGarrett WollmanThe 23476dafb89SGarrett Wollman.Nm 23576dafb89SGarrett Wollmancommand returns zero on success, or a non-zero value from 23676dafb89SGarrett Wollman.Aq Pa sysexits.h 23776dafb89SGarrett Wollmanon failure. If multiple URIs are given for retrieval, 23876dafb89SGarrett Wollman.Nm 23976dafb89SGarrett Wollmanwill attempt all of them and return zero only if all succeeded 24076dafb89SGarrett Wollman(otherwise it will return the error from the last failure). 2417fefc698SJordan K. Hubbard.Sh ENVIRONMENT 24278be3199SGarrett Wollman.Bl -tag -width FTP_PASSIVE_MODE -offset indent 24378be3199SGarrett Wollman.It Ev FTP_TIMEOUT 24478be3199SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 24578be3199SGarrett Wollman.Tn FTP 24678be3199SGarrett Wollmanconnection. 24778be3199SGarrett Wollman.It Ev FTP_LOGIN 24878be3199SGarrett Wollmanthe login name used for 24978be3199SGarrett Wollman.Tn FTP 25078be3199SGarrett Wollmantransfers (default 25178be3199SGarrett Wollman.Dq Li anonymous ) 25276dafb89SGarrett Wollman.It Ev FTP_PASSIVE_MODE 25376dafb89SGarrett Wollmanforce the use of passive mode FTP 25478be3199SGarrett Wollman.It Ev FTP_PASSWORD 25578be3199SGarrett Wollmanthe password used for 25678be3199SGarrett Wollman.Tn FTP 25778be3199SGarrett Wollmantransfers (default 25878be3199SGarrett Wollman.Dq Va yourname Ns Li \&@ Ns Va yourhost ) 25978be3199SGarrett Wollman.It Ev FTP_PROXY 2608a2f8e39SBill Fennerthe address (in the form 2618a2f8e39SBill Fenner.Do Va hostname Ns 2628a2f8e39SBill Fenner.Op Li : Ns Va port 2638a2f8e39SBill Fenner.Dc ) 2648a2f8e39SBill Fennerof a proxy server which understands 26578be3199SGarrett Wollman.Tn FTP 26676dafb89SGarrett Wollman.It Ev HTTP_AUTH 26776dafb89SGarrett Wollmandefines authentication parameters for 26876dafb89SGarrett Wollman.Tn HTTP 26976dafb89SGarrett Wollman.It Ev HTTP_PROXY 2708a2f8e39SBill Fennerthe address (in the form 2718a2f8e39SBill Fenner.Do Va hostname Ns 2728a2f8e39SBill Fenner.Op Li : Ns Va port 2738a2f8e39SBill Fenner.Dc ) 2748a2f8e39SBill Fennerof a proxy server which understands 27576dafb89SGarrett Wollman.Tn HTTP 27676dafb89SGarrett Wollman.It Ev HTTP_PROXY_AUTH 27776dafb89SGarrett Wollmandefines authentication parameters for 27876dafb89SGarrett Wollman.Tn HTTP 27976dafb89SGarrett Wollmanproxy servers 28076dafb89SGarrett Wollman.It Ev HTTP_TIMEOUT 28176dafb89SGarrett Wollmanmaximum time, in seconds, to wait before aborting an 28276dafb89SGarrett Wollman.Tn HTTP 28376dafb89SGarrett Wollmanconnection. 2847fefc698SJordan K. Hubbard.Sh SEE ALSO 285da1ff3cbSWolfram Schneider.Xr ftp 1 , 286da1ff3cbSWolfram Schneider.Xr tftp 1 2877fefc698SJordan K. Hubbard.Sh HISTORY 2887fefc698SJordan K. HubbardThe 2897fefc698SJordan K. Hubbard.Nm fetch 29085cf659aSMike Pritchardcommand appeared in 29185cf659aSMike Pritchard.Fx 2.1.5 . 29278be3199SGarrett Wollman.Sh AUTHORS 29378be3199SGarrett WollmanThe original implementation of 29478be3199SGarrett Wollman.Nm 295306005e7SPhilippe Charnierwas done by 296306005e7SPhilippe Charnier.An Jean-Marc Zucconi . 297306005e7SPhilippe CharnierIt was extensively re-worked for 298bc5d5816SWolfram Schneider.Fx 2.2 299306005e7SPhilippe Charnierby 300306005e7SPhilippe Charnier.An Garrett Wollman . 3012494e810SGarrett Wollman.Sh BUGS 3022494e810SGarrett WollmanThere are too many environment variables and command-line options. 3032494e810SGarrett Wollman.Pp 3042494e810SGarrett WollmanThe 3052494e810SGarrett Wollman.Fl a 3062494e810SGarrett Wollmanoption is only implemented for certain kinds of 3072494e810SGarrett Wollman.Tn HTTP 3082494e810SGarrett Wollmanfailures, and no 3092494e810SGarrett Wollman.Tn FTP 3102494e810SGarrett Wollmanfailures. 3112494e810SGarrett Wollman.Pp 31276dafb89SGarrett WollmanOnly the 31376dafb89SGarrett Wollman.Dq basic 31476dafb89SGarrett Wollmanauthentication mode is implemented for 31576dafb89SGarrett Wollman.Tn HTTP . 31676dafb89SGarrett WollmanThis should be replaced by digest authentication. 3170c8cc99eSGarrett Wollman.Pp 3180c8cc99eSGarrett WollmanThe 3190c8cc99eSGarrett Wollman.Fl b 3200c8cc99eSGarrett Wollmanflag should not be necessary. 321