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