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