remove restart, etc on branch
[unix-history] / usr / src / usr.bin / ftp / ftp.1
CommitLineData
cb8ade2f
KB
1.\" Copyright (c) 1985 The Regents of the University of California.
2.\" All rights reserved.
9e7fc5bf 3.\"
cb8ade2f
KB
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
ff00793c 14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
9e7fc5bf 15.\"
90eb797b 16.\" @(#)ftp.1 6.12.1.1 (Berkeley) %G%
cb8ade2f 17.\"
ff00793c 18.TH FTP 1 "February 23, 1989"
9e7fc5bf
KM
19.UC 5
20.SH NAME
1609770c 21ftp \- ARPANET file transfer program
9e7fc5bf
KM
22.SH SYNOPSIS
23.B ftp
24[
25.B \-v
26] [
27.B \-d
28] [
29.B \-i
30] [
31.B \-n
32] [
33.B \-g
34] [
a154ee89 35.B host
9e7fc5bf
KM
36]
37.SH DESCRIPTION
38.I Ftp
39is the user interface to the ARPANET standard File Transfer Protocol.
a154ee89
GM
40The program allows a user to transfer files to and from a
41remote network site.
42.PP
9e7fc5bf
KM
43The client host with which
44.I ftp
45is to communicate may be specified on the command line.
46If this is done,
47.I ftp
a154ee89
GM
48will immediately attempt to establish a connection to an FTP
49server on that host; otherwise,
50.I ftp
51will enter its command interpreter and await instructions
52from the user. When
53.I ftp
54is awaiting commands from the user the prompt \*(lqftp>\*(rq
adbdb3c0 55is provided to the user. The following commands are recognized
9e7fc5bf
KM
56by
57.IR ftp :
58.TP
a154ee89
GM
59\fB\&!\fP [ \fIcommand\fP [ \fIargs\fP ] ]
60Invoke an interactive shell on the local machine.
61If there are arguments, the first is taken to be a command to execute
62directly, with the rest of the arguments as its arguments.
63.TP
64\fB\&$\fP \fImacro-name\fP [ \fIargs\fP ]
65Execute the macro \fImacro-name\fP that was defined with the
66\fBmacdef\fP command.
67Arguments are passed to the macro unglobbed.
68.TP
69\fBaccount\fP [ \fIpasswd\fP ]
70Supply a supplemental password required by a remote system for access
71to resources once a login has been successfully completed.
72If no argument is included, the user will be prompted for an account
73password in a non-echoing input mode.
9e7fc5bf
KM
74.TP
75\fBappend\fP \fIlocal-file\fP [ \fIremote-file\fP ]
76Append a local file to a file on the remote machine. If
77.I remote-file
78is left unspecified, the local file name is used in naming the
a154ee89
GM
79remote file after being altered by any
80.I ntrans
81or
82.I nmap
83setting.
84File transfer uses the current settings for
85.IR type ,
86.IR format ,
87.IR mode ,
88and
89.IR structure .
9e7fc5bf
KM
90.TP
91.B ascii
a154ee89
GM
92Set the file transfer
93.I type
94to network ASCII. This is the default type.
9e7fc5bf
KM
95.TP
96.B bell
97Arrange that a bell be sounded after each file transfer
98command is completed.
99.TP
100.B binary
a154ee89
GM
101Set the file transfer
102.I type
103to support binary image transfer.
9e7fc5bf
KM
104.TP
105.B bye
106Terminate the FTP session with the remote server
107and exit
108.IR ftp .
3c604e97 109An end of file will also terminate the session and exit.
9e7fc5bf 110.TP
a154ee89
GM
111.B case
112Toggle remote computer file name case mapping during
113.B mget
114commands.
115When
116.B case
117is on (default is off), remote computer file names with all letters in
118upper case are written in the local directory with the letters mapped
119to lower case.
120.TP
9e7fc5bf
KM
121.BI cd " remote-directory"
122Change the working directory on the remote machine
123to
124.IR remote-directory .
125.TP
a154ee89
GM
126.B cdup
127Change the remote machine working directory to the parent of the
128current remote machine working directory.
129.TP
9e7fc5bf
KM
130.B close
131Terminate the FTP session with the remote server, and
132return to the command interpreter.
a154ee89
GM
133Any defined macros are erased.
134.TP
135.B cr
136Toggle carriage return stripping during
137ascii type file retrieval.
138Records are denoted by a carriage return/linefeed sequence
139during ascii type file transfer.
140When
141.B cr
142is on (the default), carriage returns are stripped from this
143sequence to conform with the UNIX single linefeed record
144delimiter.
145Records on non-UNIX remote systems may contain single linefeeds;
146when an ascii type transfer is made, these linefeeds may be
147distinguished from a record delimiter only when
148.B cr
149is off.
9e7fc5bf
KM
150.TP
151.BI delete " remote-file"
152Delete the file
153.I remote-file
154on the remote machine.
155.TP
156\fBdebug\fP [ \fIdebug-value\fP ]
157Toggle debugging mode. If an optional
158.I debug-value
159is specified it is used to set the debugging level.
160When debugging is on,
161.I ftp
162prints each command sent to the remote machine, preceded
163by the string \*(lq-->\*(rq.
164.TP
165\fBdir\fP [ \fIremote-directory\fP ] [ \fIlocal-file\fP ]
166Print a listing of the directory contents in the
167directory,
168.IR remote-directory ,
169and, optionally, placing the output in
170.IR local-file .
cd8a871b
KB
171If interactive prompting is on,
172.I ftp
173will prompt the user to verify that the last argument is indeed the
174target local file for receiving
175.B dir
176output.
9e7fc5bf
KM
177If no directory is specified, the current working
178directory on the remote machine is used. If no local
a154ee89 179file is specified, or \fIlocal-file\fP is \fB-\fP,
1609770c 180output comes to the terminal.
9e7fc5bf 181.TP
a154ee89
GM
182.B disconnect
183A synonym for
184.BR close .
185.TP
186.BI form " format"
187Set the file transfer
188.I form
189to
190.IR format .
191The default format is \*(lqfile\*(rq.
9e7fc5bf
KM
192.TP
193\fBget\fP \fIremote-file\fP [ \fIlocal-file\fP ]
194Retrieve the
195.I remote-file
196and store it on the local machine. If the local
197file name is not specified, it is given the same
a154ee89
GM
198name it has on the remote machine, subject to
199alteration by the current
200.IR case ,
201.IR ntrans ,
202and
203.I nmap
204settings.
205The current settings for
206.IR type ,
207.IR form ,
208.IR mode ,
209and
210.I structure
9e7fc5bf
KM
211are used while transferring the file.
212.TP
a154ee89
GM
213\fBglob\fP
214Toggle filename expansion for \fBmdelete\fP, \fBmget\fP and \fBmput\fP.
215If globbing is turned off with \fBglob\fP, the file name arguments
216are taken literally and not expanded.
217Globbing for \fBmput\fP is done as in \fBcsh\fP(1).
218For \fBmdelete\fP and \fBmget\fP, each remote file name is expanded
219separately on the remote machine and the lists are not merged.
220Expansion of a directory name is likely to be
1609770c 221different from expansion of the name of an ordinary file:
a154ee89
GM
222the exact result depends on the foreign operating system and ftp server,
223and can be previewed by doing `\fBmls\fP\ \fIremote-files\fP\ \fB-\fP'.
224Note: \fBmget\fP and \fBmput\fP are not meant to transfer
225entire directory subtrees of files. That can be done by
226transferring a \fBtar\fP(1) archive of the subtree (in binary mode).
1609770c 227.TP
a154ee89 228\fBhash\f
9e7fc5bf
KM
229Toggle hash-sign (``#'') printing for each data block
230transferred. The size of a data block is 1024 bytes.
231.TP
9e7fc5bf
KM
232\fBhelp\fP [ \fIcommand\fP ]
233Print an informative message about the meaning of
234.IR command .
235If no argument is given,
236.I ftp
237prints a list of the known commands.
238.TP
239\fBlcd\fP [ \fIdirectory\fP ]
240Change the working directory on the local machine. If
241no
242.I directory
243is specified, the user's home directory is used.
244.TP
245\fBls\fP [ \fIremote-directory\fP ] [ \fIlocal-file\fP ]
ff00793c 246Print a listing of the contents of a
cdc35b45
MK
247directory on the remote machine.
248The listing includes any system-dependent information that the server
249chooses to include; for example, most UNIX systems will produce
250output from the command \*(lqls -l\*(rq.
251(See also \fBnlist\fP.)
252If
9e7fc5bf 253.I remote-directory
cd8a871b
KB
254is left unspecified, the current working directory is used.
255If interactive prompting is on,
256.I ftp
257will prompt the user to verify that the last argument is indeed the
258target local file for receiving
259.B ls
260output.
261If no local file is specified, or if \fIlocal-file\fR is \fB-\fR,
1609770c
KM
262the output is sent to the terminal.
263.TP
a154ee89
GM
264\fBmacdef\fP \fImacro-name\fP
265Define a macro.
266Subsequent lines are stored as the macro
267\fImacro-name\fP; a null line (consecutive newline characters
268in a file or
269carriage returns from the terminal) terminates macro input mode.
270There is a limit of 16 macros and 4096 total characters in all
271defined macros.
272Macros remain defined until a
273.B close
274command is executed.
275The macro processor interprets '$' and '\\' as special characters.
276A '$' followed by a number (or numbers) is replaced by the
277corresponding argument on the macro invocation command line.
278A '$' followed by an 'i' signals that macro processor that the
279executing macro is to be looped. On the first pass '$i' is
280replaced by the first argument on the macro invocation command line,
281on the second pass it is replaced by the second argument, and so on.
282A '\\' followed by any character is replaced by that character.
283Use the '\\' to prevent special treatment of the '$'.
284.TP
1609770c
KM
285\fBmdelete\fP [ \fIremote-files\fP ]
286Delete the \fIremote-files\fP on the remote machine.
287.TP
cd800a97 288\fBmdir\fP \fIremote-files\fP \fIlocal-file\fP
1609770c 289Like \fBdir\fP, except multiple remote files may be specified.
a154ee89
GM
290If interactive prompting is on,
291.I ftp
292will prompt the user to verify that the last argument is indeed the
293target local file for receiving
294.B mdir
295output.
9e7fc5bf
KM
296.TP
297\fBmget\fP \fIremote-files\fP
1609770c
KM
298Expand the \fIremote-files\fP on the remote machine
299and do a \fBget\fP for each file name thus produced.
300See \fBglob\fR for details on the filename expansion.
a154ee89
GM
301Resulting file names will then be processed according to
302.IR case ,
303.IR ntrans ,
304and
305.I nmap
306settings.
1609770c 307Files are transferred into the local working directory,
a154ee89
GM
308which can be changed with `\fBlcd\fP\ directory';
309new local directories can be created with `\fB!\fP\ mkdir\ directory'.
9e7fc5bf
KM
310.TP
311\fBmkdir\fP \fIdirectory-name\fP
312Make a directory on the remote machine.
313.TP
cd800a97 314\fBmls\fP \fIremote-files\fP \fIlocal-file\fP
cdc35b45
MK
315Like \fBnlist\fP, except multiple remote files may be specified,
316and the \fIlocal-file\fP must be specified.
a154ee89
GM
317If interactive prompting is on,
318.I ftp
319will prompt the user to verify that the last argument is indeed the
320target local file for receiving
321.B mls
322output.
9e7fc5bf
KM
323.TP
324\fBmode\fP [ \fImode-name\fP ]
a154ee89
GM
325Set the file transfer
326.I mode
327to
9e7fc5bf 328.IR mode-name .
a154ee89 329The default mode is \*(lqstream\*(rq mode.
9e7fc5bf 330.TP
ff00793c
MK
331\fBmodtime\fP \fIfile-name\fP
332Show the last modification time of the file on the remote machine.
333.TP
9e7fc5bf 334\fBmput\fP \fIlocal-files\fP
1609770c
KM
335Expand wild cards in the list of local files given as arguments
336and do a \fBput\fR for each file in the resulting list.
337See \fBglob\fP for details of filename expansion.
a154ee89
GM
338Resulting file names will then be processed according to
339.I ntrans
340and
341.I nmap
342settings.
343.TP
ff00793c 344\fBnlist\fP [ \fIremote-directory\fP ] [ \fIlocal-file\fP ]
cdc35b45 345Print a list of the files of a
ff00793c
MK
346directory on the remote machine. If
347.I remote-directory
348is left unspecified, the current working directory is used.
349If interactive prompting is on,
350.I ftp
351will prompt the user to verify that the last argument is indeed the
352target local file for receiving
353.B nlist
354output.
355If no local file is specified, or if \fIlocal-file\fR is \fB-\fR,
356the output is sent to the terminal.
357.TP
a154ee89
GM
358\fBnmap\fP [ \fIinpattern\fP \fIoutpattern\fP ]
359Set or unset the filename mapping mechanism.
360If no arguments are specified, the filename mapping mechanism is unset.
361If arguments are specified, remote filenames are mapped during
362.B mput
363commands and
364.B put
365commands issued without a specified remote target filename.
366If arguments are specified, local filenames are mapped during
367.B mget
368commands and
369.B get
370commands issued without a specified local target filename.
371This command is useful when connecting to a non-UNIX remote computer
372with different file naming conventions or practices.
373The mapping follows the pattern set by
374.I inpattern
375and
376.IR outpattern .
377.I Inpattern
378is a template for incoming filenames (which may have already been
379processed according to the
380.B ntrans
381and
382.B case
383settings).
2c32d7db 384Variable templating is accomplished by including the sequences '$1', '$2', ..., '$9' in
a154ee89
GM
385.IR inpattern .
386Use '\\' to prevent this special treatment of the '$' character.
387All other characters are treated literally, and are used to determine the
388.B nmap
389.I inpattern
390variable values.
ff00793c 391For example, given
a154ee89
GM
392.I inpattern
393$1.$2 and the remote file name "mydata.data", $1 would have the value
394"mydata", and $2 would have the value "data".
395The
396.I outpattern
397determines the resulting mapped filename.
398The sequences '$1', '$2', ...., '$9' are replaced by any value resulting
399from the
400.I inpattern
401template.
402The sequence '$0' is replace by the original filename.
403Additionally, the sequence '[\fIseq1\fP,\fIseq2\f\P]' is replaced by
404.I seq1
405if
406.I seq1
407is not a null string; otherwise it is replaced by
408.IR seq2 .
409For example, the command "nmap $1.$2.$3 [$1,$2].[$2,file]" would yield
410the output filename "myfile.data" for input filenames "myfile.data" and
411"myfile.data.old", "myfile.file" for the input filename "myfile", and
412"myfile.myfile" for the input filename ".myfile".
413Spaces may be included in
414.IR outpattern ,
415as in the example: nmap $1 |sed "s/ *$//" > $1 .
416Use the '\\' character to prevent special treatment
417of the '$', '[', ']', and ',' characters.
418.TP
419\fBntrans\fP [ \fIinchars\fP [ \fIoutchars\fP ] ]
420Set or unset the filename character translation mechanism.
421If no arguments are specified, the filename character
422translation mechanism is unset.
423If arguments are specified, characters in
424remote filenames are translated during
425.B mput
426commands and
427.B put
428commands issued without a specified remote target filename.
429If arguments are specified, characters in
430local filenames are translated during
431.B mget
432commands and
433.B get
434commands issued without a specified local target filename.
435This command is useful when connecting to a non-UNIX remote computer
436with different file naming conventions or practices.
437Characters in a filename matching a character in
438.I inchars
439are replaced with the corresponding character in
440.IR outchars .
441If the character's position in
442.I inchars
443is longer than the length of
444.IR outchars ,
445the character is deleted from the file name.
9e7fc5bf
KM
446.TP
447\fBopen\fP \fIhost\fP [ \fIport\fP ]
448Establish a connection to the specified
449.I host
450FTP server. An optional port number may be supplied,
451in which case,
452.I ftp
453will attempt to contact an FTP server at that port.
454If the
455.I auto-login
456option is on (default),
457.I ftp
458will also attempt to automatically log the user in to
459the FTP server (see below).
460.TP
461.B prompt
462Toggle interactive prompting. Interactive prompting
463occurs during multiple file transfers to allow the
1609770c 464user to selectively retrieve or store files.
a154ee89 465If prompting is turned off (default is on), any \fBmget\fP or \fBmput\fP
1609770c 466will transfer all files, and any \fBmdelete\fP will delete all files.
9e7fc5bf 467.TP
a154ee89
GM
468\fBproxy\fP \fIftp-command\fP
469Execute an ftp command on a secondary control connection.
470This command allows simultaneous connection to two remote ftp
471servers for transferring files between the two servers.
472The first
473.B proxy
474command should be an
475.BR open ,
476to establish the secondary control connection.
477Enter the command "proxy ?" to see other ftp commands executable on the
478secondary connection.
98a310f2 479The following commands behave differently when prefaced by
a154ee89
GM
480.BR proxy :
481.B open
482will not define new macros during the auto-login process,
483.B close
484will not erase existing macro definitions,
485.B get
486and
487.B mget
488transfer files from the host on the primary control connection
489to the host on the secondary control connection, and
490.BR put ,
491.BR mput ,
492and
493.B append
494transfer files from the host on the secondary control connection
495to the host on the primary control connection.
496Third party file transfers depend upon support of the ftp protocol
497PASV command by the server on the secondary control connection.
498.TP
9e7fc5bf
KM
499\fBput\fP \fIlocal-file\fP [ \fIremote-file\fP ]
500Store a local file on the remote machine. If
501.I remote-file
502is left unspecified, the local file name is used
a154ee89
GM
503after processing according to any
504.I ntrans
505or
506.I nmap
507settings
9e7fc5bf 508in naming the remote file. File transfer uses the
a154ee89
GM
509current settings for
510.IR type ,
511.IR format ,
512.IR mode ,
513and
514.IR structure .
9e7fc5bf
KM
515.TP
516.B pwd
517Print the name of the current working directory on the remote
518machine.
519.TP
520.B quit
3c604e97
JL
521A synonym for
522.BR bye .
9e7fc5bf 523.TP
a154ee89
GM
524.BI quote " arg1 arg2 ..."
525The arguments specified are sent, verbatim, to the remote FTP
526server.
9e7fc5bf
KM
527.TP
528\fBrecv\fP \fIremote-file\fP [ \fIlocal-file\fP ]
a154ee89 529A synonym for get.
9e7fc5bf
KM
530.TP
531\fBremotehelp\fP [ \fIcommand-name\fP ]
532Request help from the remote FTP server. If a
533.I command-name
534is specified it is supplied to the server as well.
535.TP
ff00793c
MK
536\fBremotestatus\fP [ \fIfile-name\fP ]
537With no arguments, show status of remote machine. If \fIfile-name\fP
538is specified, show status of \fIfile-name\fP on remote machine.
539.TP
a154ee89 540\fBrename\fP [ \fIfrom\fP ] [ \fIto\fP ]
9e7fc5bf
KM
541Rename the file
542.I from
a154ee89 543on the remote machine, to the file
9e7fc5bf
KM
544.IR to .
545.TP
a154ee89
GM
546.B reset
547Clear reply queue.
548This command re-synchronizes command/reply sequencing with the remote
549ftp server.
ff00793c 550Resynchronization may be necessary following a violation of the ftp protocol
a154ee89
GM
551by the remote server.
552.TP
9e7fc5bf
KM
553.BI rmdir " directory-name"
554Delete a directory on the remote machine.
555.TP
a154ee89
GM
556.B runique
557Toggle storing of files on the local system with unique filenames.
558If a file already exists with a name equal to the target
559local filename for a
560.B get
561or
562.B mget
2c32d7db 563command, a ".1" is appended to the name.
a154ee89
GM
564If the resulting name matches another existing file,
565a ".2" is appended to the original name.
566If this process continues up to ".99", an error
567message is printed, and the transfer does not take place.
568The generated unique filename will be reported.
569Note that
570.B runique
571will not affect local files generated from a shell command
572(see below).
573The default value is off.
574.TP
9e7fc5bf 575\fBsend\fP \fIlocal-file\fP [ \fIremote-file\fP ]
a154ee89 576A synonym for put.
9e7fc5bf
KM
577.TP
578.B sendport
579Toggle the use of PORT commands. By default,
580.I ftp
581will attempt to use a PORT command when establishing
a154ee89
GM
582a connection for each data transfer.
583The use of PORT commands can prevent delays
584when performing multiple file transfers. If the PORT
9e7fc5bf
KM
585command fails,
586.I ftp
587will use the default data port. When the use of PORT
588commands is disabled, no attempt will be made to use
589PORT commands for each data transfer. This is useful
a154ee89
GM
590for certain FTP implementations which do ignore PORT
591commands but, incorrectly, indicate they've been accepted.
9e7fc5bf 592.TP
ff00793c
MK
593.BI size " file-name"
594Return size of \fIfile-name\fP on remote machine.
595.TP
9e7fc5bf
KM
596.B status
597Show the current status of
598.IR ftp .
599.TP
600\fBstruct\fP [ \fIstruct-name\fP ]
a154ee89
GM
601Set the file transfer
602.I structure
603to
9e7fc5bf 604.IR struct-name .
a154ee89
GM
605By default \*(lqstream\*(rq structure is used.
606.TP
607.B sunique
608Toggle storing of files on remote machine under unique file names.
609Remote ftp server must support ftp protocol STOU command for
610successful completion.
611The remote server will report unique name.
612Default value is off.
9e7fc5bf 613.TP
ff00793c
MK
614.B system
615Show the type of operating system running on the remote machine.
616.TP
9e7fc5bf 617.B tenex
a154ee89 618Set the file transfer type to that needed to
9e7fc5bf
KM
619talk to TENEX machines.
620.TP
621.B trace
a154ee89 622Toggle packet tracing.
9e7fc5bf
KM
623.TP
624\fBtype\fP [ \fItype-name\fP ]
a154ee89
GM
625Set the file transfer
626.I type
627to
9e7fc5bf
KM
628.IR type-name .
629If no type is specified, the current type
a154ee89 630is printed. The default type is network ASCII.
9e7fc5bf
KM
631.TP
632\fBuser\fP \fIuser-name\fP [ \fIpassword\fP ] [ \fIaccount\fP ]
633Identify yourself to the remote FTP server. If the
634password is not specified and the server requires it,
635.I ftp
636will prompt the user for it (after disabling local echo).
637If an account field is not specified, and the FTP server
a154ee89
GM
638requires it, the user will be prompted for it.
639If an account field is specified, an account command will
640be relayed to the remote server after the login sequence
641is completed if the remote server did not require it
642for logging in.
643Unless
9e7fc5bf
KM
644.I ftp
645is invoked with \*(lqauto-login\*(rq disabled, this
646process is done automatically on initial connection to
647the FTP server.
648.TP
649.B verbose
650Toggle verbose mode. In verbose mode, all responses from
651the FTP server are displayed to the user. In addition,
a154ee89 652if verbose is on, when a file transfer completes, statistics
9e7fc5bf 653regarding the efficiency of the transfer are reported. By default,
a154ee89 654verbose is on.
9e7fc5bf
KM
655.TP
656\fB?\fP [ \fIcommand\fP ]
a154ee89
GM
657A synonym for help.
658.PP
9e7fc5bf
KM
659Command arguments which have embedded spaces may be quoted with
660quote (") marks.
a154ee89 661.SH "ABORTING A FILE TRANSFER"
98a310f2 662To abort a file transfer, use the terminal interrupt key
a154ee89
GM
663(usually Ctrl-C).
664Sending transfers will be immediately halted.
665Receiving transfers will be halted by sending a ftp protocol ABOR
666command to the remote server, and discarding any further data received.
667The speed at which this is accomplished depends upon the remote
668server's support for ABOR processing.
98a310f2 669If the remote server does not support the ABOR command, an "ftp>"
a154ee89
GM
670prompt will not appear until the remote server has completed
671sending the requested file.
672.PP
673The terminal interrupt key sequence will be ignored when
674.I ftp
675has completed any local processing and is awaiting a reply
676from the remote server.
677A long delay in this mode may result from the ABOR processing described
678above, or from unexpected behavior by the remote server, including
679violations of the ftp protocol.
680If the delay results from unexpected remote server behavior, the local
cd800a97 681.I ftp
a154ee89 682program must be killed by hand.
9e7fc5bf 683.SH "FILE NAMING CONVENTIONS"
a154ee89 684Files specified as arguments to
9e7fc5bf
KM
685.I ftp
686commands are processed according to the following rules.
687.TP
6881)
a154ee89
GM
689If the file name \*(lq\-\*(rq is specified, the
690.B stdin
691(for reading) or
692.B stdout
9e7fc5bf
KM
693(for writing) is used.
694.TP
6952)
696If the first character of the file name is \*(lq|\*(rq, the
697remainder of the argument is interpreted as a shell command.
a154ee89 698.I Ftp
9e7fc5bf 699then forks a shell, using
a154ee89
GM
700.IR popen (3)
701with the argument supplied, and reads (writes) from the stdout
702(stdin). If the shell command includes spaces, the argument
9e7fc5bf
KM
703must be quoted; e.g. \*(lq"| ls -lt"\*(rq. A particularly
704useful example of this mechanism is: \*(lqdir |more\*(rq.
705.TP
7063)
a154ee89 707Failing the above checks, if ``globbing'' is enabled,
9e7fc5bf
KM
708local file names are expanded
709according to the rules used in the
710.IR csh (1);
a154ee89 711c.f. the
9e7fc5bf 712.I glob
a154ee89
GM
713command.
714If the
715.I ftp
716command expects a single local file ( .e.g.
717.BR put ),
718only the first filename generated by the "globbing" operation is used.
719.TP
7204)
721For
722.B mget
723commands and
724.B get
725commands with unspecified local file names, the local filename is
726the remote filename, which may be altered by a
727.BR case ,
728.BR ntrans ,
729or
730.B nmap
731setting.
732The resulting filename may then be altered if
733.B runique
734is on.
735.TP
7365)
737For
738.B mput
739commands and
740.B put
741commands with unspecified remote file names, the remote filename is
742the local filename, which may be altered by a
743.B ntrans
744or
745.B nmap
746setting.
747The resulting filename may then be altered by the remote server if
748.B sunique
749is on.
9e7fc5bf
KM
750.SH "FILE TRANSFER PARAMETERS"
751The FTP specification specifies many parameters which may
a154ee89
GM
752affect a file transfer. The
753.I type
754may be one of \*(lqascii\*(rq, \*(lqimage\*(rq (binary),
755\*(lqebcdic\*(rq, and \*(lqlocal byte size\*(rq (for PDP-10's
756and PDP-20's mostly).
757.I Ftp
758supports the ascii and image types of file transfer,
759plus local byte size 8 for \fBtenex\fP mode transfers.
760.PP
761.I Ftp
762supports only the default values for the remaining
763file transfer parameters:
764.IR mode ,
765.IR form ,
766and
767.IR struct .
9e7fc5bf
KM
768.SH OPTIONS
769Options may be specified at the command line, or to the
770command interpreter.
a154ee89
GM
771.PP
772The
9e7fc5bf 773.B \-v
a154ee89 774(verbose on) option forces
9e7fc5bf 775.I ftp
a154ee89
GM
776to show all responses from the remote server, as well
777as report on data transfer statistics.
778.PP
779The
9e7fc5bf 780.B \-n
a154ee89
GM
781option restrains
782.I ftp
783from attempting \*(lqauto-login\*(rq upon initial connection.
9e7fc5bf
KM
784If auto-login is enabled,
785.I ftp
a154ee89
GM
786will check the
787.I .netrc
788(see below) file in the user's home directory for an entry describing
9e7fc5bf
KM
789an account on the remote machine. If no entry exists,
790.I ftp
a154ee89
GM
791will prompt for the remote machine login name (default is the user
792identity on the local machine), and, if necessary, prompt for a password
793and an account with which to login.
794.PP
795The
9e7fc5bf 796.B \-i
a154ee89
GM
797option turns off interactive prompting during
798multiple file transfers.
799.PP
800The
cd800a97 801.B \-d
a154ee89
GM
802option enables debugging.
803.PP
804The
805.B \-g
806option disables file name globbing.
807.SH "THE .netrc FILE"
808The .netrc file contains login and initialization information
809used by the auto-login process.
810It resides in the user's home directory.
811The following tokens are recognized; they may be separated by spaces,
812tabs, or new-lines:
813.TP
814\fBmachine\fP \fIname\fP
815Identify a remote machine name.
816The auto-login process searches the .netrc file for a
817.B machine
2c32d7db 818token that matches the remote machine specified on the
a154ee89
GM
819.I ftp
820command line or as an
821.B open
822command argument.
a154ee89
GM
823Once a match is made, the subsequent .netrc tokens are processed,
824stopping when the end of file is reached or another
825.B machine
cdc35b45
MK
826or a
827.B default
a154ee89
GM
828token is encountered.
829.TP
cdc35b45
MK
830\fBdefault\fP
831This is the same as \fBmachine\fP \fIname\fP except that \fBdefault\fP
832matches any name.
833There can be only one \fBdefault\fP token, and it must be after all
834\fBmachine\fP tokens.
835This is normally used as:
ff00793c
MK
836.ce
837default login anonymous password user@site
838thereby giving the user \fIautomatic\fP anonymous ftp login to
839machines not specified in \fB.netrc\fP. This can be overridden
840by using the \fB\-n\fP flag to disable auto-login.
841.TP
a154ee89
GM
842\fBlogin\fP \fIname\fP
843Identify a user on the remote machine.
844If this token is present, the auto-login process will initiate
845a login using the specified name.
846.TP
847\fBpassword\fP \fIstring\fP
848Supply a password.
849If this token is present, the auto-login process will supply the
850specified string if the remote server requires a password as part
851of the login process.
cdc35b45
MK
852Note that if this token is present in the .netrc file for any user other
853than \fIanonymous\fP,
a154ee89
GM
854.I ftp
855will abort the auto-login process if the .netrc is readable by
856anyone besides the user.
857.TP
858\fBaccount\fP \fIstring\fP
859Supply an additional account password.
860If this token is present, the auto-login process will supply the
861specified string if the remote server requires an additional
862account password, or the auto-login process will initiate an
863ACCT command if it does not.
864.TP
865\fBmacdef\fP \fIname\fP
866Define a macro.
867This token functions like the
868.I ftp
869.B macdef
870command functions.
871A macro is defined with the specified name; its contents begin with the
872next .netrc line and continue until a null line (consecutive new-line
873characters) is encountered.
874If a macro named
875.I init
876is defined, it is automatically executed as the last step in the
877auto-login process.
1ff88243
KB
878.SH "SEE ALSO"
879ftpd(8)
9e7fc5bf 880.SH BUGS
a154ee89
GM
881Correct execution of many commands depends upon proper behavior
882by the remote server.
cd800a97 883.PP
98a310f2
MK
884An error in the treatment of carriage returns
885in the 4.2BSD UNIX ascii-mode transfer code
a154ee89
GM
886has been corrected.
887This correction may result in incorrect transfers of binary files
98a310f2 888to and from 4.2BSD servers using the ascii type.
a154ee89 889Avoid this problem by using the binary image type.