Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / ftp / ftp.1
1 .\" $FreeBSD: src/usr.bin/ftp/ftp.1,v 1.15.2.7 2002/08/27 09:55:08 yar Exp $
2 .\"     $NetBSD: ftp.1,v 1.21 1997/06/10 21:59:58 lukem Exp $
3 .\"
4 .\" Copyright (c) 1985, 1989, 1990, 1993
5 .\"     The Regents of the University of California.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)ftp.1       8.3 (Berkeley) 10/9/94
36 .\"
37 .Dd January 27, 2000
38 .Dt FTP 1
39 .Os
40 .Sh NAME
41 .Nm ftp , pftp , gate-ftp
42 .Nd
43 .Tn ARPANET
44 file transfer program
45 .Sh SYNOPSIS
46 .Nm
47 .Op Fl 46adeginptUvV
48 .Op Fl P Ar port
49 .Op Fl s Ar src_addr
50 .Op Ar host Op Ar port
51 .Nm
52 ftp://[\fIuser\fR:\fIpassword\fR@]\fIhost\fR[:\fIport\fR]/\fIfile\fR[/]
53 .Nm
54 http://\fIhost\fR[:\fIport\fR]/\fIfile\fR
55 .Nm
56 \fIhost\fR:[/\fIpath\fR/]\fIfile\fR[/]
57 .Sh DESCRIPTION
58 .Nm
59 is the user interface to the
60 .Tn ARPANET
61 standard File Transfer Protocol.
62 The program allows a user to transfer files to and from a
63 remote network site.
64 The version supports IPv6 (Internet protocol version 6), as well as IPv4.
65 .Pp
66 The latter three usage formats will fetch a file using either the
67 HTTP or FTP protocols into the current directory.
68 This is ideal for scripts.
69 Refer to
70 .Sx AUTO-FETCHING FILES
71 below for more information.
72 .Pp
73 Options may be specified at the command line, or to the
74 command interpreter.
75 .Bl -tag -width Fl
76 .It Fl 4
77 Forces
78 .Nm
79 to use IPv4 addresses only.
80 .It Fl 6
81 Forces
82 .Nm
83 to use IPv6 addresses only.
84 .It Fl a
85 Causes
86 .Nm
87 to bypass normal login procedure, and use an anonymous login instead.
88 .It Fl d
89 Enables debugging.
90 .It Fl e
91 Disables command line editing.
92 .It Fl g
93 Disables file name globbing.
94 .It Fl i
95 Turns off interactive prompting during
96 multiple file transfers.
97 .It Fl n
98 Restrains
99 .Nm
100 from attempting
101 .Dq auto-login
102 upon initial connection.
103 If auto-login is enabled,
104 .Nm
105 will check the
106 .Pa .netrc
107 (see below) file in the user's home directory for an entry describing
108 an account on the remote machine.
109 If no entry exists,
110 .Nm
111 will prompt for the remote machine login name (default is the user
112 identity on the local machine), and, if necessary, prompt for a password
113 and an account with which to login.
114 .It Fl p
115 Enables passive mode operation for use behind connection filtering firewalls.
116 Using the
117 .Nm pftp
118 command has the same effect.
119 .It Fl P Ar port
120 Sets the port number to
121 .Ar port .
122 .It Fl s Ar src_addr
123 Sets the local IP address for all connections to
124 .Ar src_addr ,
125 which can be an IP address or a host name.
126 .It Fl t
127 Enables packet tracing.
128 .It Fl U
129 Disable data port range restrictions.
130 .It Fl v
131 Enable verbose mode.
132 This is the default if input is from a terminal.
133 Forces
134 .Nm
135 to show all responses from the remote server, as well
136 as report on data transfer statistics.
137 .It Fl V
138 Disable verbose mode, overriding the default of enabled when input
139 is from a terminal.
140 .El
141 .Pp
142 The client host with which
143 .Nm
144 is to communicate may be specified on the command line.
145 If this is done,
146 .Nm
147 will immediately attempt to establish a connection to an
148 .Tn FTP
149 server on that host; otherwise,
150 .Nm
151 will enter its command interpreter and await instructions
152 from the user.
153 When
154 .Nm
155 is awaiting commands from the user the prompt
156 .Ql ftp>
157 is provided to the user.
158 The following commands are recognized
159 by
160 .Nm :
161 .Bl -tag -width Fl
162 .It Ic \&! Op Ar command Op Ar args
163 Invoke an interactive shell on the local machine.
164 If there are arguments, the first is taken to be a command to execute
165 directly, with the rest of the arguments as its arguments.
166 .It Ic \&$ Ar macro-name Op Ar args
167 Execute the macro
168 .Ar macro-name
169 that was defined with the
170 .Ic macdef
171 command.
172 Arguments are passed to the macro unglobbed.
173 .It Ic account Op Ar passwd
174 Supply a supplemental password required by a remote system for access
175 to resources once a login has been successfully completed.
176 If no argument is included, the user will be prompted for an account
177 password in a non-echoing input mode.
178 .It Ic append Ar local-file Op Ar remote-file
179 Append a local file to a file on the remote machine.
180 If
181 .Ar remote-file
182 is left unspecified, the local file name is used in naming the
183 remote file after being altered by any
184 .Ic ntrans
185 or
186 .Ic nmap
187 setting.
188 File transfer uses the current settings for
189 .Ic type  ,
190 .Ic format ,
191 .Ic mode
192 and
193 .Ic structure .
194 .It Ic ascii
195 Set the file transfer
196 .Ic type
197 to network
198 .Tn ASCII .
199 This is the default type.
200 .It Ic bell
201 Arrange that a bell be sounded after each file transfer
202 command is completed.
203 .It Ic binary
204 Set the file transfer
205 .Ic type
206 to support binary image transfer.
207 .It Ic bye
208 Terminate the
209 .Tn FTP
210 session with the remote server
211 and exit
212 .Nm .
213 An end of file will also terminate the session and exit.
214 .It Ic case
215 Toggle remote computer file name case mapping during
216 .Ic mget
217 commands.
218 When
219 .Ic case
220 is on (default is off), remote computer file names with all letters in
221 upper case are written in the local directory with the letters mapped
222 to lower case.
223 .It Ic \&cd Ar remote-directory
224 Change the working directory on the remote machine
225 to
226 .Ar remote-directory .
227 .It Ic cdup
228 Change the remote machine working directory to the parent of the
229 current remote machine working directory.
230 .It Ic chmod Ar mode file-name
231 Change the permission modes of the file
232 .Ar file-name
233 on the remote
234 system to
235 .Ar mode .
236 .It Ic close
237 Terminate the
238 .Tn FTP
239 session with the remote server, and
240 return to the command interpreter.
241 Any defined macros are erased.
242 .It Ic \&cr
243 Toggle carriage return stripping during
244 ascii type file retrieval.
245 Records are denoted by a carriage return/linefeed sequence
246 during ascii type file transfer.
247 When
248 .Ic \&cr
249 is on (the default), carriage returns are stripped from this
250 sequence to conform with the
251 .Ux
252 single linefeed record
253 delimiter.
254 Records on
255 .Pf non\- Ns Ux
256 remote systems may contain single linefeeds;
257 when an ascii type transfer is made, these linefeeds may be
258 distinguished from a record delimiter only when
259 .Ic \&cr
260 is off.
261 .It Ic delete Ar remote-file
262 Delete the file
263 .Ar remote-file
264 on the remote machine.
265 .It Ic debug Op Ar debug-value
266 Toggle debugging mode.
267 If an optional
268 .Ar debug-value
269 is specified, it is used to set the debugging level.
270 When debugging is on,
271 .Nm
272 prints each command sent to the remote machine, preceded
273 by the string
274 .Ql \-\->
275 .It Ic dir Op Ar remote-directory Op Ar local-file
276 Print a listing of the contents of a
277 directory on the remote machine.
278 The listing includes any system-dependent information that the server
279 chooses to include; for example, most
280 .Ux
281 systems will produce
282 output from the command
283 .Ql ls \-l .
284 (See also
285 .Ic ls . )
286 If
287 .Ar remote-directory
288 is left unspecified, the current working directory is used.
289 If interactive prompting is on,
290 .Nm
291 will prompt the user to verify that the last argument is indeed the
292 target local file for receiving
293 .Ic dir
294 output.
295 If no local file is specified, or if
296 .Ar local-file
297 is
298 .Sq Fl ,
299 the output is sent to the terminal.
300 .Pp
301 As this command provides extra information which is system-dependent,
302 you should use the
303 .Ic nlist
304 command instead if you only want a plain list of files.
305 .It Ic disconnect
306 A synonym for
307 .Ic close .
308 .It Ic edit
309 Toggle command line editing, and context sensitive command and file
310 completion.
311 This is automatically enabled if input is from a terminal, and
312 disabled otherwise.
313 .It Ic epsv4
314 Toggle use of
315 .Dv EPSV/EPRT
316 commands on IPv4 FTP sessions.
317 Turning this option off may remedy problems with some
318 firewalls, e.g., IPFilter.
319 .It Ic exit
320 A synonym for
321 .Ic bye .
322 .It Ic ftp Ar host Op Ar port
323 A synonym for
324 .Ic open .
325 .It Ic form Ar format
326 Set the file transfer
327 .Ic form
328 to
329 .Ar format .
330 The default format is \*(Lqfile\*(Rq.
331 .It Ic get Ar remote-file Op Ar local-file
332 Retrieve the
333 .Ar remote-file
334 and store it on the local machine.
335 If the local
336 file name is not specified, it is given the same
337 name it has on the remote machine, subject to
338 alteration by the current
339 .Ic case  ,
340 .Ic ntrans
341 and
342 .Ic nmap
343 settings.
344 The current settings for
345 .Ic type  ,
346 .Ic form ,
347 .Ic mode
348 and
349 .Ic structure
350 are used while transferring the file.
351 .It Ic gate Op Ar host Op Ar port
352 Toggle gate-ftp mode.
353 This will not be permitted if the gate-ftp server hasn't been set
354 (either explicitly by the user, or from the
355 .Ev FTPSERVER
356 environment variable).
357 If
358 .Ar host
359 is given,
360 then gate-ftp mode will be enabled, and the gate-ftp server will be set to
361 .Ar host .
362 If
363 .Ar port
364 is also given, that will be used as the port to connect to on the
365 gate-ftp server.
366 .It Ic glob
367 Toggle filename expansion for
368 .Ic mdelete  ,
369 .Ic mget
370 and
371 .Ic mput .
372 If globbing is turned off with
373 .Ic glob  ,
374 the file name arguments
375 are taken literally and not expanded.
376 Globbing for
377 .Ic mput
378 is done as in
379 .Xr csh 1 .
380 For
381 .Ic mdelete
382 and
383 .Ic mget  ,
384 each remote file name is expanded
385 separately on the remote machine and the lists are not merged.
386 Expansion of a directory name is likely to be
387 different from expansion of the name of an ordinary file:
388 the exact result depends on the foreign operating system and ftp server,
389 and can be previewed by doing
390 .Ql mls remote-files \-
391 Note:
392 .Ic mget
393 and
394 .Ic mput
395 are not meant to transfer
396 entire directory subtrees of files.
397 That can be done by
398 transferring a
399 .Xr tar 1
400 archive of the subtree (in binary mode).
401 .It Ic hash Op Ar size
402 Toggle hash-sign (``#'') printing for each data block
403 transferred.
404 The size of a data block defaults to 1024 bytes.
405 This can be changed by specifying
406 .Ar size
407 in bytes.
408 .It Ic help Op Ar command
409 Print an informative message about the meaning of
410 .Ar command .
411 If no argument is given,
412 .Nm
413 prints a list of the known commands.
414 .It Ic idle Op Ar seconds
415 Set the inactivity timer on the remote server to
416 .Ar seconds
417 seconds.
418 If
419 .Ar seconds
420 is omitted, the current inactivity timer is printed.
421 .It Ic lcd Op Ar directory
422 Change the working directory on the local machine.
423 If
424 no
425 .Ar directory
426 is specified, the user's home directory is used.
427 .It Ic less Ar file
428 A synonym for
429 .Ic page .
430 .It Ic lpwd
431 Print the working directory on the local machine.
432 .It Ic \&ls Op Ar remote-directory Op Ar local-file
433 A synonym for
434 .Ic dir .
435 .It Ic macdef Ar macro-name
436 Define a macro.
437 Subsequent lines are stored as the macro
438 .Ar macro-name  ;
439 a null line (consecutive newline characters
440 in a file or
441 carriage returns from the terminal) terminates macro input mode.
442 There is a limit of 16 macros and 4096 total characters in all
443 defined macros.
444 Macros remain defined until a
445 .Ic close
446 command is executed.
447 The macro processor interprets `$' and `\e' as special characters.
448 A `$' followed by a number (or numbers) is replaced by the
449 corresponding argument on the macro invocation command line.
450 A `$' followed by an `i' signals that macro processor that the
451 executing macro is to be looped.
452 On the first pass `$i' is
453 replaced by the first argument on the macro invocation command line,
454 on the second pass it is replaced by the second argument, and so on.
455 A `\e' followed by any character is replaced by that character.
456 Use the `\e' to prevent special treatment of the `$'.
457 .It Ic mdelete Op Ar remote-files
458 Delete the
459 .Ar remote-files
460 on the remote machine.
461 .It Ic mdir Ar remote-files local-file
462 Like
463 .Ic dir  ,
464 except multiple remote files may be specified.
465 If interactive prompting is on,
466 .Nm
467 will prompt the user to verify that the last argument is indeed the
468 target local file for receiving
469 .Ic mdir
470 output.
471 .It Ic mget Ar remote-files
472 Expand the
473 .Ar remote-files
474 on the remote machine
475 and do a
476 .Ic get
477 for each file name thus produced.
478 See
479 .Ic glob
480 for details on the filename expansion.
481 Resulting file names will then be processed according to
482 .Ic case  ,
483 .Ic ntrans
484 and
485 .Ic nmap
486 settings.
487 Files are transferred into the local working directory,
488 which can be changed with
489 .Ql lcd directory ;
490 new local directories can be created with
491 .Ql "\&! mkdir directory" .
492 .It Ic mkdir Ar directory-name
493 Make a directory on the remote machine.
494 .It Ic mls Ar remote-files local-file
495 Like
496 .Ic ls  ,
497 except multiple remote files may be specified,
498 and the
499 .Ar local-file
500 must be specified.
501 If interactive prompting is on,
502 .Nm
503 will prompt the user to verify that the last argument is indeed the
504 target local file for receiving
505 .Ic mls
506 output.
507 .It Ic mode Op Ar mode-name
508 Set the file transfer
509 .Ic mode
510 to
511 .Ar mode-name .
512 The default mode is \*(Lqstream\*(Rq mode.
513 .It Ic modtime Ar file-name
514 Show the last modification time of the file on the remote machine.
515 .It Ic more Ar file
516 A synonym for
517 .Ic page .
518 .It Ic mput Ar local-files
519 Expand wild cards in the list of local files given as arguments
520 and do a
521 .Ic put
522 for each file in the resulting list.
523 See
524 .Ic glob
525 for details of filename expansion.
526 Resulting file names will then be processed according to
527 .Ic ntrans
528 and
529 .Ic nmap
530 settings.
531 .It Ic msend Ar local-files
532 A synonym for
533 .Ic mput .
534 .It Ic newer Ar file-name
535 Get the file only if the modification time of the remote file is more
536 recent that the file on the current system.
537 If the file does not
538 exist on the current system, the remote file is considered
539 .Ic newer .
540 Otherwise, this command is identical to
541 .Ar get .
542 .It Ic nlist Op Ar remote-directory Op Ar local-file
543 Print a list of the files in a
544 directory on the remote machine.
545 If
546 .Ar remote-directory
547 is left unspecified, the current working directory is used.
548 If interactive prompting is on,
549 .Nm
550 will prompt the user to verify that the last argument is indeed the
551 target local file for receiving
552 .Ic ls
553 output.
554 If no local file is specified, or if
555 .Ar local-file
556 is
557 .Fl  ,
558 the output is sent to the terminal.
559 .Pp
560 Note that this command only returns the filenames in the remote
561 directory.  If you wish to see more information about the files (often
562 size, modification time, and so on),
563 you should use the
564 .Ic dir
565 command instead.
566 .It Ic nmap Op Ar inpattern outpattern
567 Set or unset the filename mapping mechanism.
568 If no arguments are specified, the filename mapping mechanism is unset.
569 If arguments are specified, remote filenames are mapped during
570 .Ic mput
571 commands and
572 .Ic put
573 commands issued without a specified remote target filename.
574 If arguments are specified, local filenames are mapped during
575 .Ic mget
576 commands and
577 .Ic get
578 commands issued without a specified local target filename.
579 This command is useful when connecting to a
580 .No non\- Ns Ux
581 remote computer
582 with different file naming conventions or practices.
583 The mapping follows the pattern set by
584 .Ar inpattern
585 and
586 .Ar outpattern .
587 .Op Ar Inpattern
588 is a template for incoming filenames (which may have already been
589 processed according to the
590 .Ic ntrans
591 and
592 .Ic case
593 settings).
594 Variable templating is accomplished by including the
595 sequences `$1', `$2', ..., `$9' in
596 .Ar inpattern .
597 Use `\\' to prevent this special treatment of the `$' character.
598 All other characters are treated literally, and are used to determine the
599 .Ic nmap
600 .Op Ar inpattern
601 variable values.
602 For example, given
603 .Ar inpattern
604 $1.$2 and the remote file name "mydata.data", $1 would have the value
605 "mydata", and $2 would have the value "data".
606 The
607 .Ar outpattern
608 determines the resulting mapped filename.
609 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
610 from the
611 .Ar inpattern
612 template.
613 The sequence `$0' is replace by the original filename.
614 Additionally, the sequence
615 .Ql Op Ar seq1 , Ar seq2
616 is replaced by
617 .Op Ar seq1
618 if
619 .Ar seq1
620 is not a null string; otherwise it is replaced by
621 .Ar seq2 .
622 For example, the command
623 .Pp
624 .Bd -literal -offset indent -compact
625 nmap $1.$2.$3 [$1,$2].[$2,file]
626 .Ed
627 .Pp
628 would yield
629 the output filename "myfile.data" for input filenames "myfile.data" and
630 "myfile.data.old", "myfile.file" for the input filename "myfile", and
631 "myfile.myfile" for the input filename ".myfile".
632 Spaces may be included in
633 .Ar outpattern  ,
634 as in the example: `nmap $1 sed "s/  *$//" > $1' .
635 Use the `\e' character to prevent special treatment
636 of the `$','[',']' and `,' characters.
637 .It Ic ntrans Op Ar inchars Op Ar outchars
638 Set or unset the filename character translation mechanism.
639 If no arguments are specified, the filename character
640 translation mechanism is unset.
641 If arguments are specified, characters in
642 remote filenames are translated during
643 .Ic mput
644 commands and
645 .Ic put
646 commands issued without a specified remote target filename.
647 If arguments are specified, characters in
648 local filenames are translated during
649 .Ic mget
650 commands and
651 .Ic get
652 commands issued without a specified local target filename.
653 This command is useful when connecting to a
654 .No non\- Ns Ux
655 remote computer
656 with different file naming conventions or practices.
657 Characters in a filename matching a character in
658 .Ar inchars
659 are replaced with the corresponding character in
660 .Ar outchars .
661 If the character's position in
662 .Ar inchars
663 is longer than the length of
664 .Ar outchars  ,
665 the character is deleted from the file name.
666 .It Ic open Ar host Op Ar port
667 Establish a connection to the specified
668 .Ar host
669 .Tn FTP
670 server.
671 An optional port number may be supplied,
672 in which case,
673 .Nm
674 will attempt to contact an
675 .Tn FTP
676 server at that port.
677 If the
678 .Ic auto-login
679 option is on (default),
680 .Nm
681 will also attempt to automatically log the user in to
682 the
683 .Tn FTP
684 server (see below).
685 .It Ic page Ar file
686 Retrieve
687 .Ic file
688 and display with the program defined in
689 .Ev PAGER
690 (which defaults to
691 .Xr more 1 ) .
692 .It Ic passive
693 Toggle passive mode.  If passive mode is turned on
694 (default is off), the ftp client will
695 send a
696 .Dv PASV
697 command for all data connections instead of the usual
698 .Dv PORT
699 command.  The
700 .Dv PASV
701 command requests that the remote server open a port for the data connection
702 and return the address of that port.  The remote server listens on that
703 port and the client connects to it.  When using the more traditional
704 .Dv PORT
705 command, the client listens on a port and sends that address to the remote
706 server, who connects back to it.  Passive mode is useful when using
707 .Nm
708 through a gateway router or host that controls the directionality of
709 traffic.
710 (Note that though ftp servers are required to support the
711 .Dv PASV
712 command by RFC 1123, some do not.
713 Please note that if you are connecting to IPv6 ftp server,
714 the program will use
715 .Dv EPSV/EPRT
716 pair and
717 .Dv LPSV/LPRT
718 pair,
719 instead of
720 .Dv PASV
721 and
722 .Dv PORT .
723 The meaning is the same.)
724 .It Ic preserve
725 Toggle preservation of modification times on retrieved files.
726 .It Ic progress
727 Toggle display of transfer progress bar.
728 The progress bar will be disabled for a transfer that has
729 .Ar local-file
730 as
731 .Sq Fl
732 or a command that starts with
733 .Sq \&| .
734 Refer to
735 .Sx FILE NAMING CONVENTIONS
736 for more information.
737 .It Ic prompt
738 Toggle interactive prompting.
739 Interactive prompting
740 occurs during multiple file transfers to allow the
741 user to selectively retrieve or store files.
742 If prompting is turned off (default is on), any
743 .Ic mget
744 or
745 .Ic mput
746 will transfer all files, and any
747 .Ic mdelete
748 will delete all files.
749 .Pp
750 When prompting is on, the following commands are available at a prompt:
751 .Bl -tag -width 2n -offset indent
752 .It Ic n
753 Do not transfer the file.
754 .It Ic a
755 Answer
756 .Sq yes
757 to the current file, and automatically answer
758 .Sq yes
759 to any remaining files for the current command.
760 .It Ic p
761 Answer
762 .Sq yes
763 to the current file, and turn off prompt mode
764 (as if
765 .Dq prompt off
766 had been given).
767 .El
768 .Pp
769 Any other reponse will answer
770 .Sq yes
771 to the current file.
772 .It Ic proxy Ar ftp-command
773 Execute an ftp command on a secondary control connection.
774 This command allows simultaneous connection to two remote ftp
775 servers for transferring files between the two servers.
776 The first
777 .Ic proxy
778 command should be an
779 .Ic open  ,
780 to establish the secondary control connection.
781 Enter the command "proxy ?" to see other ftp commands executable on the
782 secondary connection.
783 The following commands behave differently when prefaced by
784 .Ic proxy  :
785 .Ic open
786 will not define new macros during the auto-login process,
787 .Ic close
788 will not erase existing macro definitions,
789 .Ic get
790 and
791 .Ic mget
792 transfer files from the host on the primary control connection
793 to the host on the secondary control connection, and
794 .Ic put  ,
795 .Ic mput
796 and
797 .Ic append
798 transfer files from the host on the secondary control connection
799 to the host on the primary control connection.
800 Third party file transfers depend upon support of the ftp protocol
801 .Dv PASV
802 command by the server on the secondary control connection.
803 .It Ic put Ar local-file Op Ar remote-file
804 Store a local file on the remote machine.
805 If
806 .Ar remote-file
807 is left unspecified, the local file name is used
808 after processing according to any
809 .Ic ntrans
810 or
811 .Ic nmap
812 settings
813 in naming the remote file.
814 File transfer uses the
815 current settings for
816 .Ic type  ,
817 .Ic format ,
818 .Ic mode
819 and
820 .Ic structure .
821 .It Ic pwd
822 Print the name of the current working directory on the remote
823 machine.
824 .It Ic quit
825 A synonym for
826 .Ic bye .
827 .It Ic quote Ar arg1 arg2 ...
828 The arguments specified are sent, verbatim, to the remote
829 .Tn FTP
830 server.
831 .It Ic recv Ar remote-file Op Ar local-file
832 A synonym for
833 .Ic get .
834 .It Ic reget Ar remote-file Op Ar local-file
835 Reget acts like get, except that if
836 .Ar local-file
837 exists and is
838 smaller than
839 .Ar remote-file  ,
840 .Ar local-file
841 is presumed to be
842 a partially transferred copy of
843 .Ar remote-file
844 and the transfer
845 is continued from the apparent point of failure.
846 This command
847 is useful when transferring very large files over networks that
848 are prone to dropping connections.
849 .It Ic remotehelp Op Ar command-name
850 Request help from the remote
851 .Tn FTP
852 server.
853 If a
854 .Ar command-name
855 is specified it is supplied to the server as well.
856 .It Ic rstatus Op Ar file-name
857 With no arguments, show status of remote machine.
858 If
859 .Ar file-name
860 is specified, show status of
861 .Ar file-name
862 on remote machine.
863 .It Ic rename Op Ar from Op Ar to
864 Rename the file
865 .Ar from
866 on the remote machine, to the file
867 .Ar to .
868 .It Ic reset
869 Clear reply queue.
870 This command re-synchronizes command/reply sequencing with the remote
871 ftp server.
872 Resynchronization may be necessary following a violation of the ftp protocol
873 by the remote server.
874 .It Ic restart Ar marker
875 Restart the immediately following
876 .Ic get
877 or
878 .Ic put
879 at the
880 indicated
881 .Ar marker .
882 On
883 .Ux
884 systems, marker is usually a byte
885 offset into the file.
886 .It Ic restrict
887 Toggle data port range restrictions.
888 When not operating in passive mode,  the
889 .Nm
890 client program requests that the remote server open a connection back
891 to the client host on a separate data port.  In previous versions, that
892 remote port fell in the range 1024..4999.  However, most firewall setups
893 filter that range of TCP ports because other services reside there.
894 The default behavior now is for the client to request that the server
895 connect back to the client using the port range 49152..65535.  Firewall
896 administrators can chose to allow TCP connections in that range, if they
897 deem it to not be a security risk.
898 .It Ic rmdir Ar directory-name
899 Delete a directory on the remote machine.
900 .It Ic runique
901 Toggle storing of files on the local system with unique filenames.
902 If a file already exists with a name equal to the target
903 local filename for a
904 .Ic get
905 or
906 .Ic mget
907 command, a ".1" is appended to the name.
908 If the resulting name matches another existing file,
909 a ".2" is appended to the original name.
910 If this process continues up to ".99", an error
911 message is printed, and the transfer does not take place.
912 The generated unique filename will be reported.
913 Note that
914 .Ic runique
915 will not affect local files generated from a shell command
916 (see below).
917 The default value is off.
918 .It Ic send Ar local-file Op Ar remote-file
919 A synonym for
920 .Ic put .
921 .It Ic sendport
922 Toggle the use of
923 .Dv PORT
924 commands.
925 By default,
926 .Nm
927 will attempt to use a
928 .Dv PORT
929 command when establishing
930 a connection for each data transfer.
931 The use of
932 .Dv PORT
933 commands can prevent delays
934 when performing multiple file transfers.
935 If the
936 .Dv PORT
937 command fails,
938 .Nm
939 will use the default data port.
940 When the use of
941 .Dv PORT
942 commands is disabled, no attempt will be made to use
943 .Dv PORT
944 commands for each data transfer.
945 This is useful
946 for certain
947 .Tn FTP
948 implementations which do ignore
949 .Dv PORT
950 commands but, incorrectly, indicate they've been accepted.
951 .It Ic site Ar arg1 arg2 ...
952 The arguments specified are sent, verbatim, to the remote
953 .Tn FTP
954 server as a
955 .Dv SITE
956 command.
957 .It Ic size Ar file-name
958 Return size of
959 .Ar file-name
960 on remote machine.
961 .It Ic status
962 Show the current status of
963 .Nm .
964 .It Ic struct Op Ar struct-name
965 Set the file transfer
966 .Ar structure
967 to
968 .Ar struct-name .
969 By default \*(Lqstream\*(Rq structure is used.
970 .It Ic sunique
971 Toggle storing of files on remote machine under unique file names.
972 Remote ftp server must support ftp protocol
973 .Dv STOU
974 command for
975 successful completion.
976 The remote server will report unique name.
977 Default value is off.
978 .It Ic system
979 Show the type of operating system running on the remote machine.
980 .It Ic tenex
981 Set the file transfer type to that needed to
982 talk to
983 .Tn TENEX
984 machines.
985 .It Ic trace
986 Toggle packet tracing.
987 .It Ic type Op Ar type-name
988 Set the file transfer
989 .Ic type
990 to
991 .Ar type-name .
992 If no type is specified, the current type
993 is printed.
994 The default type is network
995 .Tn ASCII .
996 .It Ic umask Op Ar newmask
997 Set the default umask on the remote server to
998 .Ar newmask .
999 If
1000 .Ar newmask
1001 is omitted, the current umask is printed.
1002 .It Xo
1003 .Ic user Ar user-name
1004 .Op Ar password Op Ar account
1005 .Xc
1006 Identify yourself to the remote
1007 .Tn FTP
1008 server.
1009 If the
1010 .Ar password
1011 is not specified and the server requires it,
1012 .Nm
1013 will prompt the user for it (after disabling local echo).
1014 If an
1015 .Ar account
1016 field is not specified, and the
1017 .Tn FTP
1018 server
1019 requires it, the user will be prompted for it.
1020 If an
1021 .Ar account
1022 field is specified, an account command will
1023 be relayed to the remote server after the login sequence
1024 is completed if the remote server did not require it
1025 for logging in.
1026 Unless
1027 .Nm
1028 is invoked with \*(Lqauto-login\*(Rq disabled, this
1029 process is done automatically on initial connection to
1030 the
1031 .Tn FTP
1032 server.
1033 .It Ic verbose
1034 Toggle verbose mode.
1035 In verbose mode, all responses from
1036 the
1037 .Tn FTP
1038 server are displayed to the user.
1039 In addition,
1040 if verbose is on, when a file transfer completes, statistics
1041 regarding the efficiency of the transfer are reported.
1042 By default,
1043 verbose is on.
1044 .It Ic \&? Op Ar command
1045 A synonym for
1046 .Ic help .
1047 .El
1048 .Pp
1049 Command arguments which have embedded spaces may be quoted with
1050 quote `"' marks.
1051 .Pp
1052 Commands which toggle settings can take an explicit
1053 .Ic on
1054 or
1055 .Ic off
1056 argument to force the setting appropriately.
1057 .Pp
1058 If
1059 .Nm
1060 receives a
1061 .Dv SIGINFO
1062 (see the
1063 .Dq status
1064 argument of
1065 .Xr stty 1 )
1066 signal whilst a transfer is in progress, the current transfer rate
1067 statistics will be written to the standard error output, in the
1068 same format as the standard completion message.
1069 .Sh AUTO-FETCHING FILES
1070 In addition to standard commands, this version of
1071 .Nm
1072 supports an auto-fetch feature.
1073 To enable auto-fetch, simply pass the list of hostnames/files
1074 on the command line.
1075 .Pp
1076 The following formats are valid syntax for an auto-fetch element:
1077 .Bl -tag -width "host:/file"
1078 .It host:/file
1079 .Dq Classic
1080 ftp format
1081 .It ftp://[user:password@]host[:port]/file
1082 An ftp URL, retrieved using the ftp protocol if
1083 .Ev ftp_proxy
1084 isn't defined.
1085 Otherwise, transfer using http via the proxy defined in
1086 .Ev ftp_proxy .
1087 If
1088 .Ar user:password@
1089 is given and
1090 .Ev ftp_proxy
1091 isn't defined, login as
1092 .Ar user
1093 with a password of
1094 .Ar password .
1095 .It http://host[:port]/file
1096 An HTTP URL, retrieved using the http protocol.
1097 If
1098 .Ev http_proxy
1099 is defined, it is used as a URL to an HTTP proxy server.
1100 .El
1101 .Pp
1102 If a classic format or a ftp URL format has a trailing
1103 .Sq / ,
1104 then
1105 .Nm
1106 will connect to the site and
1107 .Ic cd
1108 to the directory given as the path, and leave the user in interactive
1109 mode ready for further input.
1110 .Pp
1111 If successive auto-fetch ftp elements refer to the same host, then
1112 the connection is maintained between transfers, reducing overhead on
1113 connection creation and deletion.
1114 .Pp
1115 If
1116 .Ic file
1117 contains a glob character and globbing is enabled,
1118 (see
1119 .Ic glob ) ,
1120 then the equivalent of
1121 .Ic "mget file"
1122 is performed.
1123 .Pp
1124 If the directory component of
1125 .Ic file
1126 contains no globbing characters,
1127 it is stored in the current directory as the
1128 .Xr basename 1
1129 of
1130 .Ic file .
1131 Otherwise, the remote name is used as the local name.
1132 .Sh ABORTING A FILE TRANSFER
1133 To abort a file transfer, use the terminal interrupt key
1134 (usually Ctrl-C).
1135 Sending transfers will be immediately halted.
1136 Receiving transfers will be halted by sending a ftp protocol
1137 .Dv ABOR
1138 command to the remote server, and discarding any further data received.
1139 The speed at which this is accomplished depends upon the remote
1140 server's support for
1141 .Dv ABOR
1142 processing.
1143 If the remote server does not support the
1144 .Dv ABOR
1145 command, an
1146 .Ql ftp>
1147 prompt will not appear until the remote server has completed
1148 sending the requested file.
1149 .Pp
1150 The terminal interrupt key sequence will be ignored when
1151 .Nm
1152 has completed any local processing and is awaiting a reply
1153 from the remote server.
1154 A long delay in this mode may result from the ABOR processing described
1155 above, or from unexpected behavior by the remote server, including
1156 violations of the ftp protocol.
1157 If the delay results from unexpected remote server behavior, the local
1158 .Nm
1159 program must be killed by hand.
1160 .Sh FILE NAMING CONVENTIONS
1161 Files specified as arguments to
1162 .Nm
1163 commands are processed according to the following rules.
1164 .Bl -enum
1165 .It
1166 If the file name
1167 .Sq Fl
1168 is specified, the
1169 .Ar stdin
1170 (for reading) or
1171 .Ar stdout
1172 (for writing) is used.
1173 .It
1174 If the first character of the file name is
1175 .Sq \&| ,
1176 the
1177 remainder of the argument is interpreted as a shell command.
1178 .Nm
1179 then forks a shell, using
1180 .Xr popen 3
1181 with the argument supplied, and reads (writes) from the stdin
1182 (stdout).
1183 If the shell command includes spaces, the argument
1184 must be quoted; e.g.\&
1185 \*(Lq" ls -lt"\*(Rq.
1186 A particularly
1187 useful example of this mechanism is: \*(Lqdir \&|more\*(Rq.
1188 .It
1189 Failing the above checks, if
1190 .Dq globbing
1191 is enabled,
1192 local file names are expanded
1193 according to the rules used in the
1194 .Xr csh 1 ;
1195 c.f. the
1196 .Ic glob
1197 command.
1198 If the
1199 .Nm
1200 command expects a single local file (e.g.\&
1201 .Ic put  ) ,
1202 only the first filename generated by the "globbing" operation is used.
1203 .It
1204 For
1205 .Ic mget
1206 commands and
1207 .Ic get
1208 commands with unspecified local file names, the local filename is
1209 the remote filename, which may be altered by a
1210 .Ic case  ,
1211 .Ic ntrans ,
1212 or
1213 .Ic nmap
1214 setting.
1215 The resulting filename may then be altered if
1216 .Ic runique
1217 is on.
1218 .It
1219 For
1220 .Ic mput
1221 commands and
1222 .Ic put
1223 commands with unspecified remote file names, the remote filename is
1224 the local filename, which may be altered by a
1225 .Ic ntrans
1226 or
1227 .Ic nmap
1228 setting.
1229 The resulting filename may then be altered by the remote server if
1230 .Ic sunique
1231 is on.
1232 .El
1233 .Sh FILE TRANSFER PARAMETERS
1234 The FTP specification specifies many parameters which may
1235 affect a file transfer.
1236 The
1237 .Ic type
1238 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1239 \*(Lqebcdic\*(Rq and \*(Lqlocal byte size\*(Rq (for
1240 .Tn PDP Ns -10's
1241 and
1242 .Tn PDP Ns -20's
1243 mostly).
1244 .Nm
1245 supports the ascii and image types of file transfer,
1246 plus local byte size 8 for
1247 .Ic tenex
1248 mode transfers.
1249 .Pp
1250 .Nm
1251 supports only the default values for the remaining
1252 file transfer parameters:
1253 .Ic mode  ,
1254 .Ic form
1255 and
1256 .Ic struct .
1257 .Sh THE .netrc FILE
1258 The
1259 .Pa .netrc
1260 file contains login and initialization information
1261 used by the auto-login process.
1262 It resides in the user's home directory.
1263 The following tokens are recognized; they may be separated by spaces,
1264 tabs, or new-lines:
1265 .Bl -tag -width password
1266 .It Ic machine Ar name
1267 Identify a remote machine
1268 .Ar name .
1269 The auto-login process searches the
1270 .Pa .netrc
1271 file for a
1272 .Ic machine
1273 token that matches the remote machine specified on the
1274 .Nm
1275 command line or as an
1276 .Ic open
1277 command argument.
1278 Once a match is made, the subsequent
1279 .Pa .netrc
1280 tokens are processed,
1281 stopping when the end of file is reached or another
1282 .Ic machine
1283 or a
1284 .Ic default
1285 token is encountered.
1286 .It Ic default
1287 This is the same as
1288 .Ic machine
1289 .Ar name
1290 except that
1291 .Ic default
1292 matches any name.
1293 There can be only one
1294 .Ic default
1295 token, and it must be after all
1296 .Ic machine
1297 tokens.
1298 This is normally used as:
1299 .Pp
1300 .Dl default login anonymous password user@site
1301 .Pp
1302 thereby giving the user
1303 .Ar automatic
1304 anonymous ftp login to
1305 machines not specified in
1306 .Pa .netrc .
1307 This can be overridden
1308 by using the
1309 .Fl n
1310 flag to disable auto-login.
1311 .It Ic login Ar name
1312 Identify a user on the remote machine.
1313 If this token is present, the auto-login process will initiate
1314 a login using the specified
1315 .Ar name .
1316 .It Ic password Ar string
1317 Supply a password.
1318 If this token is present, the auto-login process will supply the
1319 specified string if the remote server requires a password as part
1320 of the login process.
1321 Note that if this token is present in the
1322 .Pa .netrc
1323 file for any user other
1324 than
1325 .Ar anonymous  ,
1326 .Nm
1327 will abort the auto-login process if the
1328 .Pa .netrc
1329 is readable by
1330 anyone besides the user.
1331 .It Ic account Ar string
1332 Supply an additional account password.
1333 If this token is present, the auto-login process will supply the
1334 specified string if the remote server requires an additional
1335 account password, or the auto-login process will initiate an
1336 .Dv ACCT
1337 command if it does not.
1338 .It Ic macdef Ar name
1339 Define a macro.
1340 This token functions like the
1341 .Nm
1342 .Ic macdef
1343 command functions.
1344 A macro is defined with the specified name; its contents begin with the
1345 next
1346 .Pa .netrc
1347 line and continue until a null line (consecutive new-line
1348 characters) is encountered.
1349 If a macro named
1350 .Ic init
1351 is defined, it is automatically executed as the last step in the
1352 auto-login process.
1353 .El
1354 .Sh COMMAND LINE EDITING
1355 .Nm
1356 supports interactive command line editing, via the
1357 .Xr editline 3
1358 library.
1359 It is enabled with the
1360 .Ic edit
1361 command, and is enabled by default if input is from a tty.
1362 Previous lines can be recalled and edited with the arrow keys,
1363 and other GNU Emacs-style editing keys may be used as well.
1364 .Pp
1365 The
1366 .Xr editline 3
1367 library is configured with a
1368 .Pa .editrc
1369 file - refer to
1370 .Xr editrc 5
1371 for more information.
1372 .Pp
1373 An extra key binding is available to
1374 .Nm
1375 to provide context sensitive command and filename completion
1376 (including remote file completion).
1377 To use this, bind a key to the
1378 .Xr editline 3
1379 command
1380 .Ic ftp-complete .
1381 By default, this is bound to the TAB key.
1382 .Sh ENVIRONMENT
1383 .Nm
1384 utilizes the following environment variables.
1385 .Bl -tag -width "FTP_PASSIVE_MODE"
1386 .It Ev FTP_PASSIVE_MODE
1387 If this variable is set to something else than
1388 .Sq NO ,
1389 .Nm
1390 will use passive mode by default.
1391 .It Ev FTPSERVER
1392 Host to use as gate-ftp server when
1393 .Ic gate
1394 is enabled.
1395 .It Ev FTPSERVERPORT
1396 Port to use when connecting to gate-ftp server when
1397 .Ic gate
1398 is enabled.
1399 Default is port returned by a
1400 .Fn getservbyname
1401 lookup of
1402 .Dq ftpgate/tcp .
1403 .It Ev HOME
1404 For default location of a
1405 .Pa .netrc
1406 file, if one exists.
1407 .It Ev PAGER
1408 Used by
1409 .Ic page
1410 to display files.
1411 .It Ev SHELL
1412 For default shell.
1413 .It Ev ftp_proxy
1414 URL of FTP proxy to use when making FTP URL requests
1415 (if not defined, use the standard ftp protocol).
1416 .It Ev http_proxy
1417 URL of HTTP proxy to use when making HTTP URL requests.
1418 .El
1419 .Sh SEE ALSO
1420 .Xr getservbyname 3 ,
1421 .Xr editrc 5 ,
1422 .Xr services 5 ,
1423 .Xr ftpd 8
1424 .Sh NOTES
1425 The
1426 .Xr pftp 1
1427 and
1428 .Xr gate-ftp 1
1429 commands are links to
1430 .Nm .
1431 .Sh HISTORY
1432 The
1433 .Nm
1434 command appeared in
1435 .Bx 4.2 .
1436 .Pp
1437 Various features such as command line editing, context sensitive
1438 command and file completion, dynamic progress bar, automatic
1439 fetching of files, ftp and http URLs, and modification time
1440 preservation were implemented in
1441 .Nx 1.3
1442 by Luke Mewburn, with assistance from Jason Thorpe.
1443 .Pp
1444 IPv6 support was added by WIDE/KAME Project.
1445 .Sh BUGS
1446 Correct execution of many commands depends upon proper behavior
1447 by the remote server.
1448 .Pp
1449 An error in the treatment of carriage returns
1450 in the
1451 .Bx 4.2
1452 ascii-mode transfer code
1453 has been corrected.
1454 This correction may result in incorrect transfers of binary files
1455 to and from
1456 .Bx 4.2
1457 servers using the ascii type.
1458 Avoid this problem by using the binary image type.
1459 .Pp
1460 Proxying functionalities, such as
1461 .Ev ftp_proxy ,
1462 may not work for IPv6 connection.