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