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