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