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