xref: /original-bsd/usr.bin/ftp/ftp.1 (revision fa348642)
1.\" Copyright (c) 1985, 1989, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)ftp.1	6.16 (Berkeley) 03/14/91
7.\"
8.Vx
9.Vx
10.Dd
11.Dt FTP 1
12.Os BSD 4.2
13.Sh NAME
14.Nm ftp
15.Nd ARPANET file transfer program
16.Sh SYNOPSIS
17.Nm ftp
18.Op Fl v
19.Op Fl d
20.Op Fl i
21.Op Fl n
22.Op Fl g
23.Op Ar host
24.Sh DESCRIPTION
25.Nm Ftp
26is the user interface to the ARPANET standard File Transfer Protocol.
27The program allows a user to transfer files to and from a
28remote network site.
29.Pp
30Options may be specified at the command line, or to the
31command interpreter.
32.Tw Ds
33.Tp Fl v
34Verbose option forces
35.Nm ftp
36to show all responses from the remote server, as well
37as report on data transfer statistics.
38.Tp Fl n
39Restrains
40.Nm ftp
41from attempting \*(Lqauto-login\*(Rq upon initial connection.
42If auto-login is enabled,
43.Nm ftp
44will check the
45.Pa .netrc
46(see below) file in the user's home directory for an entry describing
47an account on the remote machine.  If no entry exists,
48.Nm ftp
49will prompt for the remote machine login name (default is the user
50identity on the local machine), and, if necessary, prompt for a password
51and an account with which to login.
52.Tp Fl i
53Turns off interactive prompting during
54multiple file transfers.
55.Tp Fl d
56Enables debugging.
57.Tp Fl g
58Disables file name globbing.
59.Tp
60.Pp
61The client host with which
62.Nm ftp
63is to communicate may be specified on the command line.
64If this is done,
65.Nm ftp
66will immediately attempt to establish a connection to an FTP
67server on that host; otherwise,
68.Nm ftp
69will enter its command interpreter and await instructions
70from the user.  When
71.Nm ftp
72is awaiting commands from the user the prompt
73.Ql ftp>
74is provided to the user.  The following commands are recognized
75by
76.Nm ftp  :
77.Tw Fl
78.Tp Cx Ic \&!
79.Ws
80.Op Ar command Op Ar args
81.Cx
82Invoke an interactive shell on the local machine.
83If there are arguments, the first is taken to be a command to execute
84directly, with the rest of the arguments as its arguments.
85.Tp Cx Ic \&$
86.Ws
87.Ar macro-name
88.Op Ar args
89.Cx
90Execute the macro
91.Ar macro-name
92that was defined with the
93.Ic macdef
94command.
95Arguments are passed to the macro unglobbed.
96.Tp Cx Ic account
97.Ws
98.Op Ar passwd
99.Cx
100Supply a supplemental password required by a remote system for access
101to resources once a login has been successfully completed.
102If no argument is included, the user will be prompted for an account
103password in a non-echoing input mode.
104.Tp Cx Ic append
105.Ws
106.Ar local-file
107.Ws
108.Op Ar remote-file
109.Cx
110Append a local file to a file on the remote machine.  If
111.Ar remote-file
112is left unspecified, the local file name is used in naming the
113remote file after being altered by any
114.Ic ntrans
115or
116.Ic nmap
117setting.
118File transfer uses the current settings for
119.Ic type  ,
120.Ic format ,
121.Ic mode  ,
122and
123.Ic structure .
124.Tp Ic ascii
125Set the file transfer
126.Ic type
127to network ASCII.  This is the default type.
128.Tp Ic bell
129Arrange that a bell be sounded after each file transfer
130command is completed.
131.Tp Ic binary
132Set the file transfer
133.Ic type
134to support binary image transfer.
135.Tp Ic bye
136Terminate the FTP session with the remote server
137and exit
138.Nm ftp  .
139An end of file will also terminate the session and exit.
140.Tp Ic case
141Toggle remote computer file name case mapping during
142.Ic mget
143commands.
144When
145.Ic case
146is on (default is off), remote computer file names with all letters in
147upper case are written in the local directory with the letters mapped
148to lower case.
149.Tp Cx Ic cd
150.Ws
151.Ar remote-directory
152.Cx
153Change the working directory on the remote machine
154to
155.Ar remote-directory  .
156.Tp Ic cdup
157Change the remote machine working directory to the parent of the
158current remote machine working directory.
159.Tp Cx Ic chmod
160.Ws
161.Ar mode file-name
162.Cx
163Change the permission modes of the file
164.Ar file-name
165on the remote
166sytem to
167.Ar mode  .
168.Tp Ic close
169Terminate the FTP session with the remote server, and
170return to the command interpreter.
171Any defined macros are erased.
172.Tp Ic cr
173Toggle carriage return stripping during
174ascii type file retrieval.
175Records are denoted by a carriage return/linefeed sequence
176during ascii type file transfer.
177When
178.Ic cr
179is on (the default), carriage returns are stripped from this
180sequence to conform with the UNIX single linefeed record
181delimiter.
182Records on non-UNIX remote systems may contain single linefeeds;
183when an ascii type transfer is made, these linefeeds may be
184distinguished from a record delimiter only when
185.Ic cr
186is off.
187.Tp Cx Ic delete
188.Ws
189.Ar remote-file
190.Cx
191Delete the file
192.Ar remote-file
193on the remote machine.
194.Tp Cx Ic debug
195.Ws
196.Op Ar debug-value
197.Cx
198Toggle debugging mode.  If an optional
199.Ar debug-value
200is specified it is used to set the debugging level.
201When debugging is on,
202.Nm ftp
203prints each command sent to the remote machine, preceded
204by the string
205.Ql \-\->
206.Tp Cx Ic dir
207.Ws
208.Op Ar remote-directory
209.Ws
210.Op Ar local-file
211.Cx
212Print a listing of the directory contents in the
213directory,
214.Ar remote-directory  ,
215and, optionally, placing the output in
216.Ar local-file  .
217If interactive prompting is on,
218.Nm ftp
219will prompt the user to verify that the last argument is indeed the
220target local file for receiving
221.Ic dir
222output.
223If no directory is specified, the current working
224directory on the remote machine is used.  If no local
225file is specified, or
226.Ar local-file
227is
228.Fl  ,
229output comes to the terminal.
230.Tp Ic disconnect
231A synonym for
232.Ar close  .
233.Tp Cx Ic form
234.Ws
235.Ar format
236.Cx
237Set the file transfer
238.Ic form
239to
240.Ar format  .
241The default format is \*(Lqfile\*(Rq.
242.Tp Cx Ic get
243.Ws
244.Ar remote-file
245.Ws
246.Op Ar local-file
247.Cx
248Retrieve the
249.Ar remote-file
250and store it on the local machine.  If the local
251file name is not specified, it is given the same
252name it has on the remote machine, subject to
253alteration by the current
254.Ic case  ,
255.Ic ntrans ,
256and
257.Ic nmap
258settings.
259The current settings for
260.Ic type  ,
261.Ic form ,
262.Ic mode  ,
263and
264.Ic structure
265are used while transferring the file.
266.Tp Ic glob
267Toggle filename expansion for
268.Ic mdelete  ,
269.Ic mget
270and
271.Ic mput  .
272If globbing is turned off with
273.Ic glob  ,
274the file name arguments
275are taken literally and not expanded.
276Globbing for
277.Ic mput
278is done as in
279.Xr csh 1 .
280For
281.Ic mdelete
282and
283.Ic mget  ,
284each remote file name is expanded
285separately on the remote machine and the lists are not merged.
286Expansion of a directory name is likely to be
287different from expansion of the name of an ordinary file:
288the exact result depends on the foreign operating system and ftp server,
289and can be previewed by doing
290.Ql mls remote-files \-
291Note:
292.Ic mget
293and
294.Ic mput
295are not meant to transfer
296entire directory subtrees of files.  That can be done by
297transferring a
298.Xr tar 1
299archive of the subtree (in binary mode).
300.Tp Ic hash
301Toggle hash-sign (``#'') printing for each data block
302transferred.  The size of a data block is 1024 bytes.
303.Tp Cx Ic help
304.Ws
305.Op Ar command
306.Cx
307Print an informative message about the meaning of
308.Ar command  .
309If no argument is given,
310.Nm ftp
311prints a list of the known commands.
312.Tp Cx Ic idle
313.Ws
314.Op Ar seconds
315.Cx
316Set the inactivity timer on the remote server to
317.Ar seconds
318seconds.
319If
320.Ar seconds
321is ommitted, the current inactivity timer is printed.
322.Tp Cx Ic lcd
323.Ws
324.Op Ar directory
325.Cx
326Change the working directory on the local machine.  If
327no
328.Ar directory
329is specified, the user's home directory is used.
330.Tp Cx Ic ls
331.Ws
332.Op Ar remote-directory
333.Ws
334.Op Ar local-file
335.Cx
336Print a listing of the contents of a
337directory on the remote machine.
338The listing includes any system-dependent information that the server
339chooses to include; for example, most UNIX systems will produce
340output from the command
341.Ql ls \-l .
342(See also
343.Ic nlist  .
344)
345If
346.Ar remote-directory
347is left unspecified, the current working directory is used.
348If interactive prompting is on,
349.Nm ftp
350will prompt the user to verify that the last argument is indeed the
351target local file for receiving
352.Ic ls
353output.
354If no local file is specified, or if
355.Ar local-file
356is
357.Sq Fl ,
358the output is sent to the terminal.
359.Tp Cx Ic macdef
360.Ws
361.Ar macro-name
362.Cx
363Define a macro.
364Subsequent lines are stored as the macro
365.Ar macro-name  ;
366a null line (consecutive newline characters
367in a file or
368carriage returns from the terminal) terminates macro input mode.
369There is a limit of 16 macros and 4096 total characters in all
370defined macros.
371Macros remain defined until a
372.Ic close
373command is executed.
374The macro processor interprets `$' and `\e' as special characters.
375A `$' followed by a number (or numbers) is replaced by the
376corresponding argument on the macro invocation command line.
377A `$' followed by an `i' signals that macro processor that the
378executing macro is to be looped. On the first pass `$i' is
379replaced by the first argument on the macro invocation command line,
380on the second pass it is replaced by the second argument, and so on.
381A `\e' followed by any character is replaced by that character.
382Use the `\e' to prevent special treatment of the `$'.
383.Tp Cx Ic mdelete
384.Ws
385.Op Ar remote-files
386.Cx
387Delete the
388.Ar remote-files
389on the remote machine.
390.Tp Cx Ic mdir
391.Ws
392.Ar remote-files
393.Ws
394.Ar local-file
395.Cx
396Like
397.Ic dir  ,
398except multiple remote files may be specified.
399If interactive prompting is on,
400.Nm ftp
401will prompt the user to verify that the last argument is indeed the
402target local file for receiving
403.Ic mdir
404output.
405.Tp Cx Ic mget
406.Ws
407.Ar remote-files
408.Cx
409Expand the
410.Ar remote-files
411on the remote machine
412and do a
413.Ic get
414for each file name thus produced.
415See
416.Ic glob
417for details on the filename expansion.
418Resulting file names will then be processed according to
419.Ic case  ,
420.Ic ntrans ,
421and
422.Ic nmap
423settings.
424Files are transferred into the local working directory,
425which can be changed with
426.Cx `
427.Cx Li lcd directory
428.Cx \';
429new local directories can be created with
430.Cx Li \&! mkdir directory
431.Cx \'.
432.Tp Cx Ic mkdir
433.Ws
434.Ar directory-name
435.Cx
436Make a directory on the remote machine.
437.Tp Cx Ic mls
438.Ws
439.Ar remote-files
440.Ws
441.Ar local-file
442.Cx
443Like
444.Ic nlist  ,
445except multiple remote files may be specified,
446and the
447.Ar local-file
448must be specified.
449If interactive prompting is on,
450.Nm ftp
451will prompt the user to verify that the last argument is indeed the
452target local file for receiving
453.Ic mls
454output.
455.Tp Cx Ic mode
456.Ws
457.Op Ar mode-name
458.Cx
459Set the file transfer
460.Ic mode
461to
462.Ar mode-name  .
463The default mode is \*(Lqstream\*(Rq mode.
464.Tp Cx Ic modtime
465.Ws
466.Ar file-name
467.Cx
468Show the last modification time of the file on the remote machine.
469.Tp Cx Ic mput
470.Ws
471.Ar local-files
472.Cx
473Expand wild cards in the list of local files given as arguments
474and do a
475.Ic put
476for each file in the resulting list.
477See
478.Ic glob
479for details of filename expansion.
480Resulting file names will then be processed according to
481.Ic ntrans
482and
483.Ic nmap
484settings.
485.Tp Cx Ic newer
486.Ws
487.Ar file-name
488.Cx
489Get the file only if the modification time of the remote file is more
490recent that the file on the current system. If the file does not
491exist on the current system, the remote file is considered
492.Ic newer  .
493Otherwise, this command is identical to
494.Ar get  .
495.Tp Cx Ic nlist
496.Ws
497.Op Ar remote-directory
498.Ws
499.Op Ar local-file
500.Cx
501Print a  list of the files in a
502directory on the remote machine.  If
503.Ar remote-directory
504is left unspecified, the current working directory is used.
505If interactive prompting is on,
506.Nm ftp
507will prompt the user to verify that the last argument is indeed the
508target local file for receiving
509.Ic nlist
510output.
511If no local file is specified, or if
512.Ar local-file
513is
514.Fl  ,
515the output is sent to the terminal.
516.Tp Cx Ic nmap
517.Ws
518.Op Ar inpattern outpattern
519.Cx
520Set or unset the filename mapping mechanism.
521If no arguments are specified, the filename mapping mechanism is unset.
522If arguments are specified, remote filenames are mapped during
523.Ic mput
524commands and
525.Ic put
526commands issued without a specified remote target filename.
527If arguments are specified, local filenames are mapped during
528.Ic mget
529commands and
530.Ic get
531commands issued without a specified local target filename.
532This command is useful when connecting to a non-UNIX remote computer
533with different file naming conventions or practices.
534The mapping follows the pattern set by
535.Ar inpattern
536and
537.Ar outpattern  .
538.Op Ar Inpattern
539is a template for incoming filenames (which may have already been
540processed according to the
541.Ic ntrans
542and
543.Ic case
544settings).
545Variable templating is accomplished by including the sequences `$1', `$2', ..., `$9' in
546.Ar inpattern  .
547Use `\\' to prevent this special treatment of the `$' character.
548All other characters are treated literally, and are used to determine the
549.Ic nmap
550.Op Ar inpattern
551variable values.
552For example, given
553.Ar inpattern
554$1.$2 and the remote file name "mydata.data", $1 would have the value
555"mydata", and $2 would have the value "data".
556The
557.Ar outpattern
558determines the resulting mapped filename.
559The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
560from the
561.Ar inpattern
562template.
563The sequence `$0' is replace by the original filename.
564Additionally, the sequence
565.Cx `
566.Op Ar seq1 , Ar seq2
567.Cx \'
568.Cx
569is replaced by
570.Op Ar seq1
571if
572.Ar seq1
573is not a null string; otherwise it is replaced by
574.Ar seq2 .
575For example, the command
576.Pp
577.Df I
578nmap $1.$2.$3
579.Cx Op $1,$2
580.Cx .
581.Op $2,file
582.Cx
583.De
584.Pp
585would yield
586the output filename "myfile.data" for input filenames "myfile.data" and
587"myfile.data.old", "myfile.file" for the input filename "myfile", and
588"myfile.myfile" for the input filename ".myfile".
589Spaces may be included in
590.Ar outpattern  ,
591as in the example: `nmap $1 sed "s/  *$//" > $1' .
592Use the `\e' character to prevent special treatment
593of the `$','[','[', and `,' characters.
594.Tp Cx Ic ntrans
595.Ws
596.Op Ar inchars Op Ar outchars
597.Cx
598Set or unset the filename character translation mechanism.
599If no arguments are specified, the filename character
600translation mechanism is unset.
601If arguments are specified, characters in
602remote filenames are translated during
603.Ic mput
604commands and
605.Ic put
606commands issued without a specified remote target filename.
607If arguments are specified, characters in
608local filenames are translated during
609.Ic mget
610commands and
611.Ic get
612commands issued without a specified local target filename.
613This command is useful when connecting to a non-UNIX remote computer
614with different file naming conventions or practices.
615Characters in a filename matching a character in
616.Ar inchars
617are replaced with the corresponding character in
618.Ar outchars  .
619If the character's position in
620.Ar inchars
621is longer than the length of
622.Ar outchars  ,
623the character is deleted from the file name.
624.Tp Cx Ic open
625.Ws
626.Ar host
627.Ws
628.Op Ar port
629.Cx
630Establish a connection to the specified
631.Ar host
632FTP server.  An optional port number may be supplied,
633in which case,
634.Nm ftp
635will attempt to contact an FTP server at that port.
636If the
637.Ic auto-login
638option is on (default),
639.Nm ftp
640will also attempt to automatically log the user in to
641the FTP server (see below).
642.Tp Ic prompt
643Toggle interactive prompting.  Interactive prompting
644occurs during multiple file transfers to allow the
645user to selectively retrieve or store files.
646If prompting is turned off (default is on), any
647.Ic mget
648or
649.Ic mput
650will transfer all files, and any
651.Ic mdelete
652will delete all files.
653.Tp Cx Ic proxy
654.Ws
655.Ar ftp-command
656.Cx
657Execute an ftp command on a secondary control connection.
658This command allows simultaneous connection to two remote ftp
659servers for transferring files between the two servers.
660The first
661.Ic proxy
662command should be an
663.Ic open  ,
664to establish the secondary control connection.
665Enter the command "proxy ?" to see other ftp commands executable on the
666secondary connection.
667The following commands behave differently when prefaced by
668.Ic proxy  :
669.Ic open
670will not define new macros during the auto-login process,
671.Ic close
672will not erase existing macro definitions,
673.Ic get
674and
675.Ic mget
676transfer files from the host on the primary control connection
677to the host on the secondary control connection, and
678.Ic put  ,
679.Ic mput ,
680and
681.Ic append
682transfer files from the host on the secondary control connection
683to the host on the primary control connection.
684Third party file transfers depend upon support of the ftp protocol
685PASV command by the server on the secondary control connection.
686.Tp Cx Ic put
687.Ws
688.Ar local-file
689.Ws
690.Op Ar remote-file
691.Cx
692Store a local file on the remote machine.  If
693.Ar remote-file
694is left unspecified, the local file name is used
695after processing according to any
696.Ic ntrans
697or
698.Ic nmap
699settings
700in naming the remote file.  File transfer uses the
701current settings for
702.Ic type  ,
703.Ic format ,
704.Ic mode  ,
705and
706.Ic structure  .
707.Tp Ic pwd
708Print the name of the current working directory on the remote
709machine.
710.Tp Ic quit
711A synonym for
712.Ic bye  .
713.Tp Cx Ic quote
714.Ws
715.Ar arg1 arg2 ...
716.Cx
717The arguments specified are sent, verbatim, to the remote FTP
718server.
719.Tp Cx Ic recv
720.Ws
721.Ar remote-file
722.Ws
723.Op Ar local-file
724.Cx
725A synonym for get.
726.Tp Cx Ic reget
727.Ws
728.Ar remote-file
729.Ws
730.Op Ar local-file
731.Cx
732Reget acts like get, except that if
733.Ar local-file
734exists and is
735smaller than
736.Ar remote-file  ,
737.Ar local-file
738is presumed to be
739a partially transferred copy of
740.Ar remote-file
741and the transfer
742is continued from the apparent point of failure. This command
743is useful when transferring very large files over networks that
744are prone to dropping connections.
745.Tp Cx Ic remotehelp
746.Ws
747.Op Ar command-name
748.Cx
749Request help from the remote FTP server.  If a
750.Ar command-name
751is specified it is supplied to the server as well.
752.Tp Cx Ic remotestatus
753.Ws
754.Op Ar file-name
755.Cx
756With no arguments, show status of remote machine. If
757.Ar file-name
758is specified, show status of
759.Ar file-name
760on remote machine.
761.Tp Cx Ic rename
762.Ws
763.Op Ar from
764.Ws
765.Op Ar to
766.Cx
767Rename the file
768.Ar from
769on the remote machine, to the file
770.Ar to  .
771.Tp Ic reset
772Clear reply queue.
773This command re-synchronizes command/reply sequencing with the remote
774ftp server.
775Resynchronization may be necessary following a violation of the ftp protocol
776by the remote server.
777.Tp Cx Ic restart
778.Ws
779.Ar marker
780.Cx
781Restart the immediately following
782.Ic get
783or
784.Ic put
785at the
786indicated
787.Ar marker  .
788On UNIX systems, marker is usually a byte
789offset into the file.
790.Tp Cx Ic rmdir
791.Ws
792.Ar directory-name
793.Cx
794Delete a directory on the remote machine.
795.Tp Ic runique
796Toggle storing of files on the local system with unique filenames.
797If a file already exists with a name equal to the target
798local filename for a
799.Ic get
800or
801.Ic mget
802command, a ".1" is appended to the name.
803If the resulting name matches another existing file,
804a ".2" is appended to the original name.
805If this process continues up to ".99", an error
806message is printed, and the transfer does not take place.
807The generated unique filename will be reported.
808Note that
809.Ic runique
810will not affect local files generated from a shell command
811(see below).
812The default value is off.
813.Tp Cx Ic send
814.Ws
815.Ar local-file
816.Ws
817.Op Ar remote-file
818.Cx
819A synonym for put.
820.Tp Ic sendport
821Toggle the use of PORT commands.  By default,
822.Nm ftp
823will attempt to use a PORT command when establishing
824a connection for each data transfer.
825The use of PORT commands can prevent delays
826when performing multiple file transfers. If the PORT
827command fails,
828.Nm ftp
829will use the default data port.  When the use of PORT
830commands is disabled, no attempt will be made to use
831PORT commands for each data transfer.  This is useful
832for certain FTP implementations which do ignore PORT
833commands but, incorrectly, indicate they've been accepted.
834.Tp Cx Ic site
835.Ws
836.Ar arg1 arg2 ...
837.Cx
838The arguments specified are sent, verbatim, to the remote FTP
839server as a SITE command.
840.Tp Cx Ic size
841.Ws
842.Ar file-name
843.Cx
844Return size of
845.Ar file-name
846on remote machine.
847.Tp Ic status
848Show the current status of
849.Nm ftp  .
850.Tp Cx Ic struct
851.Ws
852.Op Ar struct-name
853.Cx
854Set the file transfer
855.Ar structure
856to
857.Ar struct-name .
858By default \*(Lqstream\*(Rq structure is used.
859.Tp Ic sunique
860Toggle storing of files on remote machine under unique file names.
861Remote ftp server must support ftp protocol STOU command for
862successful completion.
863The remote server will report unique name.
864Default value is off.
865.Tp Ic system
866Show the type of operating system running on the remote machine.
867.Tp Ic tenex
868Set the file transfer type to that needed to
869talk to TENEX machines.
870.Tp Ic trace
871Toggle packet tracing.
872.Tp Cx Ic type
873.Ws
874.Op Ar type-name
875.Cx
876Set the file transfer
877.Ic type
878to
879.Ar type-name  .
880If no type is specified, the current type
881is printed.  The default type is network ASCII.
882.Tp Cx Ic umask
883.Ws
884.Op Ar newmask
885.Cx
886Set the default umask on the remote server to
887.Ar newmask  .
888If
889.Ar newmask
890is ommitted, the current umask is printed.
891.Tp Cx Ic user
892.Ws
893.Ar user-name
894.Ws
895.Op Ar password
896.Ws
897.Op Ar account
898.Cx
899Identify yourself to the remote FTP server.  If the
900.Ar password
901is not specified and the server requires it,
902.Nm ftp
903will prompt the user for it (after disabling local echo).
904If an
905.Ar account
906field is not specified, and the FTP server
907requires it, the user will be prompted for it.
908If an
909.Ar account
910field is specified, an account command will
911be relayed to the remote server after the login sequence
912is completed if the remote server did not require it
913for logging in.
914Unless
915.Nm ftp
916is invoked with \*(Lqauto-login\*(Rq disabled, this
917process is done automatically on initial connection to
918the FTP server.
919.Tp Ic verbose
920Toggle verbose mode.  In verbose mode, all responses from
921the FTP server are displayed to the user.  In addition,
922if verbose is on, when a file transfer completes, statistics
923regarding the efficiency of the transfer are reported.  By default,
924verbose is on.
925.Tp Cx Ic ?
926.Ws
927.Op Ar command
928.Cx
929A synonym for help.
930.Tp
931.Pp
932Command arguments which have embedded spaces may be quoted with
933quote `"' marks.
934.Sh ABORTING A FILE TRANSFER
935To abort a file transfer, use the terminal interrupt key
936(usually Ctrl-C).
937Sending transfers will be immediately halted.
938Receiving transfers will be halted by sending a ftp protocol ABOR
939command to the remote server, and discarding any further data received.
940The speed at which this is accomplished depends upon the remote
941server's support for ABOR processing.
942If the remote server does not support the ABOR command, an
943.Ql ftp>
944prompt will not appear until the remote server has completed
945sending the requested file.
946.Pp
947The terminal interrupt key sequence will be ignored when
948.Nm ftp
949has completed any local processing and is awaiting a reply
950from the remote server.
951A long delay in this mode may result from the ABOR processing described
952above, or from unexpected behavior by the remote server, including
953violations of the ftp protocol.
954If the delay results from unexpected remote server behavior, the local
955.Nm ftp
956program must be killed by hand.
957.Sh FILE NAMING CONVENTIONS
958Files specified as arguments to
959.Nm ftp
960commands are processed according to the following rules.
961.Tw Ds
962.Tp \&1)
963If the file name
964.Sq Fl
965is specified, the
966.Ar stdin
967(for reading) or
968.Ar stdout
969(for writing) is used.
970.Tp \&2)
971If the first character of the file name is
972.Sq \&| ,
973the
974remainder of the argument is interpreted as a shell command.
975.Nm Ftp
976then forks a shell, using
977.Xr popen 3
978with the argument supplied, and reads (writes) from the stdout
979(stdin).  If the shell command includes spaces, the argument
980must be quoted; e.g. \*(Lq" ls -lt"\*(Rq.  A particularly
981useful example of this mechanism is: \*(Lqdir more\*(Rq.
982.Tp \&3)
983Failing the above checks, if ``globbing'' is enabled,
984local file names are expanded
985according to the rules used in the
986.Xr csh  1  ;
987c.f. the
988.Ic glob
989command.
990If the
991.Nm ftp
992command expects a single local file (.e.g.
993.Ic put  ) ,
994only the first filename generated by the "globbing" operation is used.
995.Tp \&4)
996For
997.Ic mget
998commands and
999.Ic get
1000commands with unspecified local file names, the local filename is
1001the remote filename, which may be altered by a
1002.Ic case  ,
1003.Ic ntrans ,
1004or
1005.Ic nmap
1006setting.
1007The resulting filename may then be altered if
1008.Ic runique
1009is on.
1010.Tp \&5)
1011For
1012.Ic mput
1013commands and
1014.Ic put
1015commands with unspecified remote file names, the remote filename is
1016the local filename, which may be altered by a
1017.Ic ntrans
1018or
1019.Ic nmap
1020setting.
1021The resulting filename may then be altered by the remote server if
1022.Ic sunique
1023is on.
1024.Tp
1025.Sh FILE TRANSFER PARAMETERS
1026The FTP specification specifies many parameters which may
1027affect a file transfer.  The
1028.Ic type
1029may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1030\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for PDP-10's
1031and PDP-20's mostly).
1032.Nm Ftp
1033supports the ascii and image types of file transfer,
1034plus local byte size 8 for
1035.Ic tenex
1036mode transfers.
1037.Pp
1038.Nm Ftp
1039supports only the default values for the remaining
1040file transfer parameters:
1041.Ic mode  ,
1042.Ic form ,
1043and
1044.Ic struct  .
1045.Sh THE .netrc FILE
1046The
1047.Pa .netrc
1048file contains login and initialization information
1049used by the auto-login process.
1050It resides in the user's home directory.
1051The following tokens are recognized; they may be separated by spaces,
1052tabs, or new-lines:
1053.Tw password
1054.Tp Cx Ic machine
1055.Ws
1056.Ar name
1057.Cx
1058Identify a remote machine
1059.Ar name .
1060The auto-login process searches the
1061.Pa .netrc
1062file for a
1063.Ic machine
1064token that matches the remote machine specified on the
1065.Nm ftp
1066command line or as an
1067.Ic open
1068command argument.
1069Once a match is made, the subsequent
1070.Pa .netrc
1071tokens are processed,
1072stopping when the end of file is reached or another
1073.Ic machine
1074or a
1075.Ic default
1076token is encountered.
1077.Tp Ic default
1078This is the same as
1079.Ic machine
1080.Ar name
1081except that
1082.Ic default
1083matches any name.
1084There can be only one
1085.Ic default
1086token, and it must be after all
1087.Ic machine
1088tokens.
1089This is normally used as:
1090.Pp
1091.Dl default login anonymous password user@site
1092.Pp
1093thereby giving the user
1094.Ar automatic
1095anonymous ftp login to
1096machines not specified in
1097.Pa .netrc .
1098This can be overridden
1099by using the
1100.Fl n
1101flag to disable auto-login.
1102.Tp Cx Ic login
1103.Ws
1104.Ar name
1105.Cx
1106Identify a user on the remote machine.
1107If this token is present, the auto-login process will initiate
1108a login using the specified
1109.Ar name .
1110.Tp Cx Ic password
1111.Ws
1112.Ar string
1113.Cx
1114Supply a password.
1115If this token is present, the auto-login process will supply the
1116specified string if the remote server requires a password as part
1117of the login process.
1118Note that if this token is present in the
1119.Pa .netrc
1120file for any user other
1121than
1122.Ar anonymous  ,
1123.Nm ftp
1124will abort the auto-login process if the
1125.Pa .netrc
1126is readable by
1127anyone besides the user.
1128.Tp Cx Ic account
1129.Ws
1130.Ar string
1131.Cx
1132Supply an additional account password.
1133If this token is present, the auto-login process will supply the
1134specified string if the remote server requires an additional
1135account password, or the auto-login process will initiate an
1136ACCT command if it does not.
1137.Tp Cx Ic macdef
1138.Ws
1139.Ar name
1140.Cx
1141Define a macro.
1142This token functions like the
1143.Nm ftp
1144.Ic macdef
1145command functions.
1146A macro is defined with the specified name; its contents begin with the
1147next
1148.Pa .netrc
1149line and continue until a null line (consecutive new-line
1150characters) is encountered.
1151If a macro named
1152.Ic init
1153is defined, it is automatically executed as the last step in the
1154auto-login process.
1155.Tp
1156.Sh ENVIRONMENT
1157.Nm Ftp
1158utilizes the following environment variables.
1159.Tw Fl
1160.Tp Ev HOME
1161For default location of a
1162.Pa .netrc
1163file, if one exists.
1164.Tp Ev SHELL
1165For default shell.
1166.Tp
1167.Sh SEE ALSO
1168.Xr ftpd 8
1169.Sh HISTORY
1170.Nm Ftp
1171appeared in 4.2 BSD.
1172.Sh BUGS
1173Correct execution of many commands depends upon proper behavior
1174by the remote server.
1175.Pp
1176An error in the treatment of carriage returns
1177in the 4.2BSD UNIX ascii-mode transfer code
1178has been corrected.
1179This correction may result in incorrect transfers of binary files
1180to and from 4.2BSD servers using the ascii type.
1181Avoid this problem by using the binary image type.
1182