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