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