Import of NetBSD's ftp client under its new name (tnftp)
[dragonfly.git] / contrib / tnftp / ftp.1
1 .\"     $NetBSD: ftp.1,v 1.114 2006/10/27 01:29:17 lukem Exp $
2 .\"
3 .\" Copyright (c) 1996-2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Luke Mewburn.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\"    must display the following acknowledgement:
19 .\"     This product includes software developed by the NetBSD
20 .\"     Foundation, Inc. and its contributors.
21 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
22 .\"    contributors may be used to endorse or promote products derived
23 .\"    from this software without specific prior written permission.
24 .\"
25 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 .\" POSSIBILITY OF SUCH DAMAGE.
36 .\"
37 .\"
38 .\" Copyright (c) 1985, 1989, 1990, 1993
39 .\"     The Regents of the University of California.  All rights reserved.
40 .\"
41 .\" Redistribution and use in source and binary forms, with or without
42 .\" modification, are permitted provided that the following conditions
43 .\" are met:
44 .\" 1. Redistributions of source code must retain the above copyright
45 .\"    notice, this list of conditions and the following disclaimer.
46 .\" 2. Redistributions in binary form must reproduce the above copyright
47 .\"    notice, this list of conditions and the following disclaimer in the
48 .\"    documentation and/or other materials provided with the distribution.
49 .\" 3. Neither the name of the University nor the names of its contributors
50 .\"    may be used to endorse or promote products derived from this software
51 .\"    without specific prior written permission.
52 .\"
53 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 .\" SUCH DAMAGE.
64 .\"
65 .\"     @(#)ftp.1       8.3 (Berkeley) 10/9/94
66 .\"
67 .Dd October 27, 2006
68 .Dt FTP 1
69 .Os
70 .Sh NAME
71 .Nm ftp
72 .Nd
73 Internet file transfer program
74 .Sh SYNOPSIS
75 .Nm
76 .Op Fl 46AadefginpRtvV
77 .Bk -words
78 .Op Fl N Ar netrc
79 .Ek
80 .Bk -words
81 .Op Fl o Ar output
82 .Ek
83 .Bk -words
84 .Op Fl P Ar port
85 .Ek
86 .Bk -words
87 .Op Fl q Ar quittime
88 .Ek
89 .Bk -words
90 .Op Fl r Ar retry
91 .Ek
92 .Bk -words
93 .\" [-T dir,max[,inc]]
94 .Oo
95 .Fl T Xo
96 .Sm off
97 .Ar dir ,
98 .Ar max
99 .Op , Ar inc
100 .Sm on
101 .Xc
102 .Oc
103 .Ek
104 .Bk -words
105 .\" [[user@]host [port]]
106 .Oo
107 .Oo Ar user Ns Li \&@ Oc Ns Ar host
108 .Op Ar port
109 .Oc
110 .Ek
111 .Bk -words
112 .\" [[user@]host:[path][/]]
113 .Sm off
114 .Oo
115 .Op Ar user Li \&@
116 .Ar host Li \&:
117 .Op Ar path
118 .Op Li /
119 .Oc
120 .Sm on
121 .Ek
122 .Bk -words
123 .\" [file:///path]
124 .Sm off
125 .Oo
126 .Li file:/// Ar path
127 .Oc
128 .Sm on
129 .Ek
130 .Bk -words
131 .\" [ftp://[user[:password]@]host[:port]/path[/]]
132 .Sm off
133 .Oo
134 .Li ftp://
135 .Oo Ar user
136 .Op Li \&: Ar password
137 .Li \&@ Oc
138 .Ar host Oo Li \&: Ar port Oc
139 .Li / Ar path
140 .Op Li /
141 .Op Li ;type= Ar X
142 .Oc
143 .Sm on
144 .Ek
145 .Bk -words
146 .\" [http://[user[:password]@]host[:port]/path]
147 .Sm off
148 .Oo
149 .Li http://
150 .Oo Ar user
151 .Op Li \&: Ar password
152 .Li \&@ Oc
153 .Ar host Oo Li \&: Ar port Oc
154 .Li / Ar path
155 .Oc
156 .Sm on
157 .Ek
158 .Op Ar \&.\&.\&.
159 .Nm
160 .Bk -words
161 .Fl u Ar URL Ar file
162 .Ek
163 .Op Ar \&.\&.\&.
164 .Sh DESCRIPTION
165 .Nm
166 is the user interface to the Internet standard File Transfer Protocol.
167 The program allows a user to transfer files to and from a
168 remote network site.
169 .Pp
170 The last five arguments will fetch a file using the
171 .Tn FTP
172 or
173 .Tn HTTP
174 protocols, or by direct copying, into the current directory.
175 This is ideal for scripts.
176 Refer to
177 .Sx AUTO-FETCHING FILES
178 below for more information.
179 .Pp
180 Options may be specified at the command line, or to the
181 command interpreter.
182 .Bl -tag -width "port   "
183 .It Fl 4
184 Forces
185 .Nm
186 to only use IPv4 addresses.
187 .It Fl 6
188 Forces
189 .Nm
190 to only use IPv6 addresses.
191 .It Fl A
192 Force active mode ftp.
193 By default,
194 .Nm
195 will try to use passive mode ftp and fall back to active mode
196 if passive is not supported by the server.
197 This option causes
198 .Nm
199 to always use an active connection.
200 It is only useful for connecting to very old servers that do not
201 implement passive mode properly.
202 .It Fl a
203 Causes
204 .Nm
205 to bypass normal login procedure, and use an anonymous login instead.
206 .It Fl d
207 Enables debugging.
208 .It Fl e
209 Disables command line editing.
210 This is useful for Emacs ange-ftp mode.
211 .It Fl f
212 Forces a cache reload for transfers that go through the
213 .Tn FTP
214 or
215 .Tn HTTP
216 proxies.
217 .It Fl g
218 Disables file name globbing.
219 .It Fl i
220 Turns off interactive prompting during
221 multiple file transfers.
222 .It Fl n
223 Restrains
224 .Nm
225 from attempting
226 .Dq auto-login
227 upon initial connection for non auto-fetch transfers.
228 If auto-login is enabled,
229 .Nm
230 will check the
231 .Pa .netrc
232 (see below) file in the user's home directory for an entry describing
233 an account on the remote machine.
234 If no entry exists,
235 .Nm
236 will prompt for the remote machine login name (default is the user
237 identity on the local machine), and, if necessary, prompt for a password
238 and an account with which to login.
239 To override the auto-login for auto-fetch transfers, specify the
240 username (and optionally, password) as appropriate.
241 .It Fl N Ar netrc
242 Use
243 .Ar netrc
244 instead of
245 .Pa ~/.netrc .
246 Refer to
247 .Sx THE .netrc FILE
248 for more information.
249 .It Fl o Ar output
250 When auto-fetching files, save the contents in
251 .Ar output .
252 .Ar output
253 is parsed according to the
254 .Sx FILE NAMING CONVENTIONS
255 below.
256 If
257 .Ar output
258 is not
259 .Sq -
260 or doesn't start with
261 .Sq \&| ,
262 then only the first file specified will be retrieved into
263 .Ar output ;
264 all other files will be retrieved into the basename of their
265 remote name.
266 .It Fl p
267 Enable passive mode operation for use behind connection filtering firewalls.
268 This option has been deprecated as
269 .Nm
270 now tries to use passive mode by default, falling back to active mode
271 if the server does not support passive connections.
272 .It Fl P Ar port
273 Sets the port number to
274 .Ar port .
275 .It Fl r Ar wait
276 Retry the connection attempt if it failed, pausing for
277 .Ar wait
278 seconds.
279 .It Fl q Ar quittime
280 Quit if the connection has stalled for
281 .Ar quittime
282 seconds.
283 .It Fl R
284 Restart all non-proxied auto-fetches.
285 .It Fl t
286 Enables packet tracing.
287 .It Xo
288 .Fl T
289 .Sm off
290 .Ar direction ,
291 .Ar maximum
292 .Op , Ar increment
293 .Sm on
294 .Xc
295 Set the maximum transfer rate for
296 .Ar direction
297 to
298 .Ar maximum
299 bytes/second,
300 and if specified, the increment to
301 .Ar increment
302 bytes/second.
303 Refer to
304 .Ic rate
305 for more information.
306 .It Fl u Ar URL file Op \&.\&.\&.
307 Upload files on the command line to
308 .Ar URL
309 where
310 .Ar URL
311 is one of the ftp URL types as supported by auto-fetch
312 (with an optional target filename for single file uploads), and
313 .Ar file
314 is one or more local files to be uploaded.
315 .It Fl v
316 Enable
317 .Ic verbose
318 and
319 .Ic progress .
320 This is the default if output is to a terminal (and in the case of
321 .Ic progress ,
322 .Nm
323 is the foreground process).
324 Forces
325 .Nm
326 to show all responses from the remote server, as well
327 as report on data transfer statistics.
328 .It Fl V
329 Disable
330 .Ic verbose
331 and
332 .Ic progress ,
333 overriding the default of enabled when output is to a terminal.
334 .El
335 .Pp
336 The client host with which
337 .Nm
338 is to communicate may be specified on the command line.
339 If this is done,
340 .Nm
341 will immediately attempt to establish a connection to an
342 .Tn FTP
343 server on that host; otherwise,
344 .Nm
345 will enter its command interpreter and await instructions
346 from the user.
347 When
348 .Nm
349 is awaiting commands from the user the prompt
350 .Ql ftp\*[Gt]
351 is provided to the user.
352 The following commands are recognized
353 by
354 .Nm ftp  :
355 .Bl -tag -width Fl
356 .It Ic \&! Op Ar command Op Ar args
357 Invoke an interactive shell on the local machine.
358 If there are arguments, the first is taken to be a command to execute
359 directly, with the rest of the arguments as its arguments.
360 .It Ic \&$ Ar macro-name Op Ar args
361 Execute the macro
362 .Ar macro-name
363 that was defined with the
364 .Ic macdef
365 command.
366 Arguments are passed to the macro unglobbed.
367 .It Ic account Op Ar passwd
368 Supply a supplemental password required by a remote system for access
369 to resources once a login has been successfully completed.
370 If no argument is included, the user will be prompted for an account
371 password in a non-echoing input mode.
372 .It Ic append Ar local-file Op Ar remote-file
373 Append a local file to a file on the remote machine.
374 If
375 .Ar remote-file
376 is left unspecified, the local file name is used in naming the
377 remote file after being altered by any
378 .Ic ntrans
379 or
380 .Ic nmap
381 setting.
382 File transfer uses the current settings for
383 .Ic type  ,
384 .Ic format ,
385 .Ic mode  ,
386 and
387 .Ic structure .
388 .It Ic ascii
389 Set the file transfer
390 .Ic type
391 to network
392 .Tn ASCII .
393 This is the default type.
394 .It Ic bell
395 Arrange that a bell be sounded after each file transfer
396 command is completed.
397 .It Ic binary
398 Set the file transfer
399 .Ic type
400 to support binary image transfer.
401 .It Ic bye
402 Terminate the
403 .Tn FTP
404 session with the remote server
405 and exit
406 .Nm ftp .
407 An end of file will also terminate the session and exit.
408 .It Ic case
409 Toggle remote computer file name case mapping during
410 .Ic get ,
411 .Ic mget
412 and
413 .Ic mput
414 commands.
415 When
416 .Ic case
417 is on (default is off), remote computer file names with all letters in
418 upper case are written in the local directory with the letters mapped
419 to lower case.
420 .It Ic \&cd Ar remote-directory
421 Change the working directory on the remote machine
422 to
423 .Ar remote-directory .
424 .It Ic cdup
425 Change the remote machine working directory to the parent of the
426 current remote machine working directory.
427 .It Ic chmod Ar mode remote-file
428 Change the permission modes of the file
429 .Ar remote-file
430 on the remote
431 system to
432 .Ar mode .
433 .It Ic close
434 Terminate the
435 .Tn FTP
436 session with the remote server, and
437 return to the command interpreter.
438 Any defined macros are erased.
439 .It Ic \&cr
440 Toggle carriage return stripping during
441 ascii type file retrieval.
442 Records are denoted by a carriage return/linefeed sequence
443 during ascii type file transfer.
444 When
445 .Ic \&cr
446 is on (the default), carriage returns are stripped from this
447 sequence to conform with the
448 .Ux
449 single linefeed record
450 delimiter.
451 Records on
452 .Pf non\- Ns Ux
453 remote systems may contain single linefeeds;
454 when an ascii type transfer is made, these linefeeds may be
455 distinguished from a record delimiter only when
456 .Ic \&cr
457 is off.
458 .It Ic ftp_debug Op Ar ftp_debug-value
459 Toggle debugging mode.
460 If an optional
461 .Ar ftp_debug-value
462 is specified it is used to set the debugging level.
463 When debugging is on,
464 .Nm
465 prints each command sent to the remote machine, preceded
466 by the string
467 .Ql \-\-\*[Gt]
468 .It Ic delete Ar remote-file
469 Delete the file
470 .Ar remote-file
471 on the remote machine.
472 .It Ic dir Op Ar remote-path Op Ar local-file
473 Print a listing of the contents of a
474 directory on the remote machine.
475 The listing includes any system-dependent information that the server
476 chooses to include; for example, most
477 .Ux
478 systems will produce
479 output from the command
480 .Ql ls \-l .
481 If
482 .Ar remote-path
483 is left unspecified, the current working directory is used.
484 If interactive prompting is on,
485 .Nm
486 will prompt the user to verify that the last argument is indeed the
487 target local file for receiving
488 .Ic dir
489 output.
490 If no local file is specified, or if
491 .Ar local-file
492 is
493 .Sq Fl ,
494 the output is sent to the terminal.
495 .It Ic disconnect
496 A synonym for
497 .Ic close .
498 .It Ic edit
499 Toggle command line editing, and context sensitive command and file
500 completion.
501 This is automatically enabled if input is from a terminal, and
502 disabled otherwise.
503 .It Ic epsv4
504 Toggle the use of the extended
505 .Dv EPSV
506 and
507 .Dv EPRT
508 commands on IPv4 connections; first try
509 .Dv EPSV /
510 .Dv EPRT ,
511 and then
512 .Dv PASV /
513 .Dv PORT .
514 This is enabled by default.
515 If an extended command fails then this option will be temporarily
516 disabled for the duration of the current connection, or until
517 .Ic epsv4
518 is executed again.
519 .It Ic exit
520 A synonym for
521 .Ic bye .
522 .It Ic features
523 Display what features the remote server supports (using the
524 .Dv FEAT
525 command).
526 .It Ic fget Ar localfile
527 Retrieve the files listed in
528 .Ar localfile ,
529 which has one line per filename.
530 .It Ic form Ar format
531 Set the file transfer
532 .Ic form
533 to
534 .Ar format .
535 The default (and only supported)
536 format is
537 .Dq non-print .
538 .It Ic ftp Ar host Op Ar port
539 A synonym for
540 .Ic open .
541 .It Ic gate Op Ar host Op Ar port
542 Toggle gate-ftp mode, which used to connect through the
543 TIS FWTK and Gauntlet ftp proxies.
544 This will not be permitted if the gate-ftp server hasn't been set
545 (either explicitly by the user, or from the
546 .Ev FTPSERVER
547 environment variable).
548 If
549 .Ar host
550 is given,
551 then gate-ftp mode will be enabled, and the gate-ftp server will be set to
552 .Ar host .
553 If
554 .Ar port
555 is also given, that will be used as the port to connect to on the
556 gate-ftp server.
557 .It Ic get Ar remote-file Op Ar local-file
558 Retrieve the
559 .Ar remote-file
560 and store it on the local machine.
561 If the local
562 file name is not specified, it is given the same
563 name it has on the remote machine, subject to
564 alteration by the current
565 .Ic case  ,
566 .Ic ntrans ,
567 and
568 .Ic nmap
569 settings.
570 The current settings for
571 .Ic type  ,
572 .Ic form ,
573 .Ic mode  ,
574 and
575 .Ic structure
576 are used while transferring the file.
577 .It Ic glob
578 Toggle filename expansion for
579 .Ic mdelete  ,
580 .Ic mget ,
581 .Ic mput ,
582 and
583 .Ic mreget .
584 If globbing is turned off with
585 .Ic glob  ,
586 the file name arguments
587 are taken literally and not expanded.
588 Globbing for
589 .Ic mput
590 is done as in
591 .Xr csh 1 .
592 For
593 .Ic mdelete ,
594 .Ic mget ,
595 and
596 .Ic mreget ,
597 each remote file name is expanded
598 separately on the remote machine and the lists are not merged.
599 Expansion of a directory name is likely to be
600 different from expansion of the name of an ordinary file:
601 the exact result depends on the foreign operating system and ftp server,
602 and can be previewed by doing
603 .Ql mls remote-files \-
604 Note:
605 .Ic mget ,
606 .Ic mput
607 and
608 .Ic mreget
609 are not meant to transfer
610 entire directory subtrees of files.
611 That can be done by
612 transferring a
613 .Xr tar 1
614 archive of the subtree (in binary mode).
615 .It Ic hash Op Ar size
616 Toggle hash-sign
617 .Pq Sq #
618 printing for each data block transferred.
619 The size of a data block defaults to 1024 bytes.
620 This can be changed by specifying
621 .Ar size
622 in bytes.
623 Enabling
624 .Ic hash
625 disables
626 .Ic progress .
627 .It Ic help Op Ar command
628 Print an informative message about the meaning of
629 .Ar command .
630 If no argument is given,
631 .Nm
632 prints a list of the known commands.
633 .It Ic idle Op Ar seconds
634 Set the inactivity timer on the remote server to
635 .Ar seconds
636 seconds.
637 If
638 .Ar seconds
639 is omitted, the current inactivity timer is printed.
640 .It Ic image
641 A synonym for
642 .Ic binary .
643 .It Ic lcd Op Ar directory
644 Change the working directory on the local machine.
645 If
646 no
647 .Ar directory
648 is specified, the user's home directory is used.
649 .It Ic less Ar file
650 A synonym for
651 .Ic page .
652 .It Ic lpage Ar local-file
653 Display
654 .Ar local-file
655 with the program specified by the
656 .Ic "set pager"
657 option.
658 .It Ic lpwd
659 Print the working directory on the local machine.
660 .It Ic \&ls Op Ar remote-path Op Ar local-file
661 A synonym for
662 .Ic dir .
663 .It Ic macdef Ar macro-name
664 Define a macro.
665 Subsequent lines are stored as the macro
666 .Ar macro-name  ;
667 a null line (consecutive newline characters in a file or carriage
668 returns from the terminal) terminates macro input mode.
669 There is a limit of 16 macros and 4096 total characters in all
670 defined macros.
671 Macro names can be a maximum of 8 characters.
672 Macros are only applicable to the current session they are
673 defined within (or if defined outside a session, to the session
674 invoked with the next
675 .Ic open
676 command), and remain defined until a
677 .Ic close
678 command is executed.
679 To invoke a macro, use the
680 .Ic $
681 command (see above).
682 .Pp
683 The macro processor interprets
684 .Sq $
685 and
686 .Sq \e
687 as special characters.
688 A
689 .Sq $
690 followed by a number (or numbers) is replaced by the
691 corresponding argument on the macro invocation command line.
692 A
693 .Sq $
694 followed by an
695 .Sq i
696 signals the macro processor that the executing macro is to be
697 looped.
698 On the first pass
699 .Dq $i
700 is replaced by the first argument on the macro invocation command
701 line, on the second pass it is replaced by the second argument,
702 and so on.
703 A
704 .Sq \e
705 followed by any character is replaced by that character.
706 Use the
707 .Sq \e
708 to prevent special treatment of the
709 .Sq $ .
710 .It Ic mdelete Op Ar remote-files
711 Delete the
712 .Ar remote-files
713 on the remote machine.
714 .It Ic mdir Ar remote-files local-file
715 Like
716 .Ic dir  ,
717 except multiple remote files may be specified.
718 If interactive prompting is on,
719 .Nm
720 will prompt the user to verify that the last argument is indeed the
721 target local file for receiving
722 .Ic mdir
723 output.
724 .It Ic mget Ar remote-files
725 Expand the
726 .Ar remote-files
727 on the remote machine
728 and do a
729 .Ic get
730 for each file name thus produced.
731 See
732 .Ic glob
733 for details on the filename expansion.
734 Resulting file names will then be processed according to
735 .Ic case  ,
736 .Ic ntrans ,
737 and
738 .Ic nmap
739 settings.
740 Files are transferred into the local working directory,
741 which can be changed with
742 .Ql lcd directory ;
743 new local directories can be created with
744 .Ql "\&! mkdir directory" .
745 .It Ic mkdir Ar directory-name
746 Make a directory on the remote machine.
747 .It Ic mls Ar remote-files local-file
748 Like
749 .Ic ls  ,
750 except multiple remote files may be specified,
751 and the
752 .Ar local-file
753 must be specified.
754 If interactive prompting is on,
755 .Nm
756 will prompt the user to verify that the last argument is indeed the
757 target local file for receiving
758 .Ic mls
759 output.
760 .It Ic mlsd Op Ar remote-path
761 Display the contents of
762 .Ar remote-path
763 (which should default to the current directory if not given)
764 in a machine-parsable form, using
765 .Dv MLSD .
766 The format of display can be changed with
767 .Sq "remopts mlst ..." .
768 .It Ic mlst Op Ar remote-path
769 Display the details about
770 .Ar remote-path
771 (which should default to the current directory if not given)
772 in a machine-parsable form, using
773 .Dv MLST .
774 The format of display can be changed with
775 .Sq "remopts mlst ..." .
776 .It Ic mode Ar mode-name
777 Set the file transfer
778 .Ic mode
779 to
780 .Ar mode-name .
781 The default (and only supported)
782 mode is
783 .Dq stream .
784 .It Ic modtime Ar remote-file
785 Show the last modification time of the file on the remote machine.
786 .It Ic more Ar file
787 A synonym for
788 .Ic page .
789 .It Ic mput Ar local-files
790 Expand wild cards in the list of local files given as arguments
791 and do a
792 .Ic put
793 for each file in the resulting list.
794 See
795 .Ic glob
796 for details of filename expansion.
797 Resulting file names will then be processed according to
798 .Ic ntrans
799 and
800 .Ic nmap
801 settings.
802 .It Ic mreget Ar remote-files
803 As per
804 .Ic mget ,
805 but performs a
806 .Ic reget
807 instead of
808 .Ic get .
809 .It Ic msend Ar local-files
810 A synonym for
811 .Ic mput .
812 .It Ic newer Ar remote-file Op Ar local-file
813 Get the file only if the modification time of the remote file is more
814 recent that the file on the current system.
815 If the file does not
816 exist on the current system, the remote file is considered
817 .Ic newer .
818 Otherwise, this command is identical to
819 .Ar get .
820 .It Ic nlist Op Ar remote-path Op Ar local-file
821 A synonym for
822 .Ic ls .
823 .It Ic nmap Op Ar inpattern outpattern
824 Set or unset the filename mapping mechanism.
825 If no arguments are specified, the filename mapping mechanism is unset.
826 If arguments are specified, remote filenames are mapped during
827 .Ic mput
828 commands and
829 .Ic put
830 commands issued without a specified remote target filename.
831 If arguments are specified, local filenames are mapped during
832 .Ic mget
833 commands and
834 .Ic get
835 commands issued without a specified local target filename.
836 This command is useful when connecting to a
837 .No non\- Ns Ux
838 remote computer
839 with different file naming conventions or practices.
840 The mapping follows the pattern set by
841 .Ar inpattern
842 and
843 .Ar outpattern .
844 .Op Ar Inpattern
845 is a template for incoming filenames (which may have already been
846 processed according to the
847 .Ic ntrans
848 and
849 .Ic case
850 settings).
851 Variable templating is accomplished by including the
852 sequences
853 .Dq $1 ,
854 .Dq $2 ,
855 \&...
856 .Dq $9
857 in
858 .Ar inpattern .
859 Use
860 .Sq \e
861 to prevent this special treatment of the
862 .Sq $
863 character.
864 All other characters are treated literally, and are used to determine the
865 .Ic nmap
866 .Op Ar inpattern
867 variable values.
868 For example, given
869 .Ar inpattern
870 $1.$2 and the remote file name "mydata.data", $1 would have the value
871 "mydata", and $2 would have the value "data".
872 The
873 .Ar outpattern
874 determines the resulting mapped filename.
875 The sequences
876 .Dq $1 ,
877 .Dq $2 ,
878 \&...
879 .Dq $9
880 are replaced by any value resulting from the
881 .Ar inpattern
882 template.
883 The sequence
884 .Dq $0
885 is replaced by the original filename.
886 Additionally, the sequence
887 .Dq Op Ar seq1 , Ar seq2
888 is replaced by
889 .Op Ar seq1
890 if
891 .Ar seq1
892 is not a null string; otherwise it is replaced by
893 .Ar seq2 .
894 For example, the command
895 .Pp
896 .Bd -literal -offset indent -compact
897 nmap $1.$2.$3 [$1,$2].[$2,file]
898 .Ed
899 .Pp
900 would yield
901 the output filename "myfile.data" for input filenames "myfile.data" and
902 "myfile.data.old", "myfile.file" for the input filename "myfile", and
903 "myfile.myfile" for the input filename ".myfile".
904 Spaces may be included in
905 .Ar outpattern  ,
906 as in the example:
907 .Dl nmap $1 sed "s/  *$//" \*[Gt] $1
908 Use the
909 .Sq \e
910 character to prevent special treatment
911 of the
912 .Sq $ ,
913 .Sq \&[ ,
914 .Sq \&] ,
915 and
916 .Sq \&,
917 characters.
918 .It Ic ntrans Op Ar inchars Op Ar outchars
919 Set or unset the filename character translation mechanism.
920 If no arguments are specified, the filename character
921 translation mechanism is unset.
922 If arguments are specified, characters in
923 remote filenames are translated during
924 .Ic mput
925 commands and
926 .Ic put
927 commands issued without a specified remote target filename.
928 If arguments are specified, characters in
929 local filenames are translated during
930 .Ic mget
931 commands and
932 .Ic get
933 commands issued without a specified local target filename.
934 This command is useful when connecting to a
935 .No non\- Ns Ux
936 remote computer
937 with different file naming conventions or practices.
938 Characters in a filename matching a character in
939 .Ar inchars
940 are replaced with the corresponding character in
941 .Ar outchars .
942 If the character's position in
943 .Ar inchars
944 is longer than the length of
945 .Ar outchars  ,
946 the character is deleted from the file name.
947 .It Ic open Ar host Op Ar port
948 Establish a connection to the specified
949 .Ar host
950 .Tn FTP
951 server.
952 An optional port number may be supplied,
953 in which case,
954 .Nm
955 will attempt to contact an
956 .Tn FTP
957 server at that port.
958 If the
959 .Ic "set auto-login"
960 option is on (default),
961 .Nm
962 will also attempt to automatically log the user in to
963 the
964 .Tn FTP
965 server (see below).
966 .It Ic page Ar file
967 Retrieve
968 .Ic file
969 and display with the program specified by the
970 .Ic "set pager"
971 option.
972 .It Ic passive Op Cm auto
973 Toggle passive mode (if no arguments are given).
974 If
975 .Cm auto
976 is given, act as if
977 .Ev FTPMODE
978 is set to
979 .Sq auto .
980 If passive mode is turned on (default),
981 .Nm
982 will send a
983 .Dv PASV
984 command for all data connections instead of a
985 .Dv PORT
986 command.
987 The
988 .Dv PASV
989 command requests that the remote server open a port for the data connection
990 and return the address of that port.
991 The remote server listens on that port and the client connects to it.
992 When using the more traditional
993 .Dv PORT
994 command, the client listens on a port and sends that address to the remote
995 server, who connects back to it.
996 Passive mode is useful when using
997 .Nm
998 through a gateway router or host that controls the directionality of
999 traffic.
1000 (Note that though
1001 .Tn FTP
1002 servers are required to support the
1003 .Dv PASV
1004 command by
1005 .Li RFC 1123 ,
1006 some do not.)
1007 .It Ic pdir Op Ar remote-path
1008 Perform
1009 .Ic dir
1010 .Op Ar remote-path ,
1011 and display the result with the program specified by the
1012 .Ic "set pager"
1013 option.
1014 .It Ic pls Op Ar remote-path
1015 Perform
1016 .Ic ls
1017 .Op Ar remote-path ,
1018 and display the result with the program specified by the
1019 .Ic "set pager"
1020 option.
1021 .It Ic pmlsd Op Ar remote-path
1022 Perform
1023 .Ic mlsd
1024 .Op Ar remote-path ,
1025 and display the result with the program specified by the
1026 .Ic "set pager"
1027 option.
1028 .It Ic preserve
1029 Toggle preservation of modification times on retrieved files.
1030 .It Ic progress
1031 Toggle display of transfer progress bar.
1032 The progress bar will be disabled for a transfer that has
1033 .Ar local-file
1034 as
1035 .Sq Fl
1036 or a command that starts with
1037 .Sq \&| .
1038 Refer to
1039 .Sx FILE NAMING CONVENTIONS
1040 for more information.
1041 Enabling
1042 .Ic progress
1043 disables
1044 .Ic hash .
1045 .It Ic prompt
1046 Toggle interactive prompting.
1047 Interactive prompting
1048 occurs during multiple file transfers to allow the
1049 user to selectively retrieve or store files.
1050 If prompting is turned off (default is on), any
1051 .Ic mget
1052 or
1053 .Ic mput
1054 will transfer all files, and any
1055 .Ic mdelete
1056 will delete all files.
1057 .Pp
1058 When prompting is on, the following commands are available at a prompt:
1059 .Bl -tag -width 2n -offset indent
1060 .It Cm a
1061 Answer
1062 .Sq yes
1063 to the current file, and automatically answer
1064 .Sq yes
1065 to any remaining files for the current command.
1066 .It Cm n
1067 Answer
1068 .Sq no ,
1069 and do not transfer the file.
1070 .It Cm p
1071 Answer
1072 .Sq yes
1073 to the current file, and turn off prompt mode
1074 (as is
1075 .Dq prompt off
1076 had been given).
1077 .It Cm q
1078 Terminate the current operation.
1079 .It Cm y
1080 Answer
1081 .Sq yes ,
1082 and transfer the file.
1083 .It Cm \&?
1084 Display a help message.
1085 .El
1086 .Pp
1087 Any other response will answer
1088 .Sq yes
1089 to the current file.
1090 .It Ic proxy Ar ftp-command
1091 Execute an ftp command on a secondary control connection.
1092 This command allows simultaneous connection to two remote
1093 .Tn FTP
1094 servers for transferring files between the two servers.
1095 The first
1096 .Ic proxy
1097 command should be an
1098 .Ic open  ,
1099 to establish the secondary control connection.
1100 Enter the command "proxy ?" to see other
1101 .Tn FTP
1102 commands executable on the secondary connection.
1103 The following commands behave differently when prefaced by
1104 .Ic proxy  :
1105 .Ic open
1106 will not define new macros during the auto-login process,
1107 .Ic close
1108 will not erase existing macro definitions,
1109 .Ic get
1110 and
1111 .Ic mget
1112 transfer files from the host on the primary control connection
1113 to the host on the secondary control connection, and
1114 .Ic put  ,
1115 .Ic mput ,
1116 and
1117 .Ic append
1118 transfer files from the host on the secondary control connection
1119 to the host on the primary control connection.
1120 Third party file transfers depend upon support of the
1121 .Tn FTP
1122 protocol
1123 .Dv PASV
1124 command by the server on the secondary control connection.
1125 .It Ic put Ar local-file Op Ar remote-file
1126 Store a local file on the remote machine.
1127 If
1128 .Ar remote-file
1129 is left unspecified, the local file name is used
1130 after processing according to any
1131 .Ic ntrans
1132 or
1133 .Ic nmap
1134 settings
1135 in naming the remote file.
1136 File transfer uses the
1137 current settings for
1138 .Ic type  ,
1139 .Ic format ,
1140 .Ic mode  ,
1141 and
1142 .Ic structure .
1143 .It Ic pwd
1144 Print the name of the current working directory on the remote
1145 machine.
1146 .It Ic quit
1147 A synonym for
1148 .Ic bye .
1149 .It Ic quote Ar arg1 arg2 ...
1150 The arguments specified are sent, verbatim, to the remote
1151 .Tn FTP
1152 server.
1153 .It Xo
1154 .Ic rate Ar direction
1155 .Op Ar maximum Op Ar increment
1156 .Xc
1157 Throttle the maximum transfer rate to
1158 .Ar maximum
1159 bytes/second.
1160 If
1161 .Ar maximum
1162 is 0, disable the throttle.
1163 .Pp
1164 .Ar direction
1165 may be one of:
1166 .Bl -tag -width "all" -offset indent -compact
1167 .It Cm all
1168 Both directions.
1169 .It Cm get
1170 Incoming transfers.
1171 .It Cm put
1172 Outgoing transfers.
1173 .El
1174 .Pp
1175 .Ar maximum
1176 can be modified on the fly by
1177 .Ar increment
1178 bytes (default: 1024) each time a given signal is received:
1179 .B
1180 .Bl -tag -width "SIGUSR1" -offset indent
1181 .It Dv SIGUSR1
1182 Increment
1183 .Ar maximum
1184 by
1185 .Ar increment
1186 bytes.
1187 .It Dv SIGUSR2
1188 Decrement
1189 .Ar maximum
1190 by
1191 .Ar increment
1192 bytes.
1193 The result must be a positive number.
1194 .El
1195 .Pp
1196 If
1197 .Ar maximum
1198 is not supplied, the current throttle rates are displayed.
1199 .Pp
1200 Note:
1201 .Ic rate
1202 is not yet implemented for ascii mode transfers.
1203 .It Ic rcvbuf Ar size
1204 Set the size of the socket receive buffer to
1205 .Ar size .
1206 .It Ic recv Ar remote-file Op Ar local-file
1207 A synonym for
1208 .Ic get .
1209 .It Ic reget Ar remote-file Op Ar local-file
1210 .Ic reget
1211 acts like
1212 .Ic get ,
1213 except that if
1214 .Ar local-file
1215 exists and is
1216 smaller than
1217 .Ar remote-file  ,
1218 .Ar local-file
1219 is presumed to be
1220 a partially transferred copy of
1221 .Ar remote-file
1222 and the transfer
1223 is continued from the apparent point of failure.
1224 This command
1225 is useful when transferring very large files over networks that
1226 are prone to dropping connections.
1227 .It Ic remopts Ar command Op Ar command-options
1228 Set options on the remote
1229 .Tn FTP
1230 server for
1231 .Ar command
1232 to
1233 .Ar command-options
1234 (whose absence is handled on a command-specific basis).
1235 Remote
1236 .Tn FTP
1237 commands known to support options include:
1238 .Sq MLST
1239 (used for
1240 .Dv MLSD
1241 and
1242 .Dv MLST ) .
1243 .It Ic rename Op Ar from Op Ar to
1244 Rename the file
1245 .Ar from
1246 on the remote machine, to the file
1247 .Ar to .
1248 .It Ic reset
1249 Clear reply queue.
1250 This command re-synchronizes command/reply sequencing with the remote
1251 .Tn FTP
1252 server.
1253 Resynchronization may be necessary following a violation of the
1254 .Tn FTP
1255 protocol by the remote server.
1256 .It Ic restart Ar marker
1257 Restart the immediately following
1258 .Ic get
1259 or
1260 .Ic put
1261 at the
1262 indicated
1263 .Ar marker .
1264 On
1265 .Ux
1266 systems, marker is usually a byte
1267 offset into the file.
1268 .It Ic rhelp Op Ar command-name
1269 Request help from the remote
1270 .Tn FTP
1271 server.
1272 If a
1273 .Ar command-name
1274 is specified it is supplied to the server as well.
1275 .It Ic rmdir Ar directory-name
1276 Delete a directory on the remote machine.
1277 .It Ic rstatus Op Ar remote-file
1278 With no arguments, show status of remote machine.
1279 If
1280 .Ar remote-file
1281 is specified, show status of
1282 .Ar remote-file
1283 on remote machine.
1284 .It Ic runique
1285 Toggle storing of files on the local system with unique filenames.
1286 If a file already exists with a name equal to the target
1287 local filename for a
1288 .Ic get
1289 or
1290 .Ic mget
1291 command, a ".1" is appended to the name.
1292 If the resulting name matches another existing file,
1293 a ".2" is appended to the original name.
1294 If this process continues up to ".99", an error
1295 message is printed, and the transfer does not take place.
1296 The generated unique filename will be reported.
1297 Note that
1298 .Ic runique
1299 will not affect local files generated from a shell command
1300 (see below).
1301 The default value is off.
1302 .It Ic send Ar local-file Op Ar remote-file
1303 A synonym for
1304 .Ic put .
1305 .It Ic sendport
1306 Toggle the use of
1307 .Dv PORT
1308 commands.
1309 By default,
1310 .Nm
1311 will attempt to use a
1312 .Dv PORT
1313 command when establishing
1314 a connection for each data transfer.
1315 The use of
1316 .Dv PORT
1317 commands can prevent delays
1318 when performing multiple file transfers.
1319 If the
1320 .Dv PORT
1321 command fails,
1322 .Nm
1323 will use the default data port.
1324 When the use of
1325 .Dv PORT
1326 commands is disabled, no attempt will be made to use
1327 .Dv PORT
1328 commands for each data transfer.
1329 This is useful
1330 for certain
1331 .Tn FTP
1332 implementations which do ignore
1333 .Dv PORT
1334 commands but, incorrectly, indicate they've been accepted.
1335 .It Ic set Op Ar option Ar value
1336 Set
1337 .Ar option
1338 to
1339 .Ar value .
1340 If
1341 .Ar option
1342 and
1343 .Ar value
1344 are not given, display all of the options and their values.
1345 The currently supported options are:
1346 .Bl -tag -width "http_proxy" -offset indent
1347 .It Cm anonpass
1348 Defaults to
1349 .Ev $FTPANONPASS
1350 .It Cm ftp_proxy
1351 Defaults to
1352 .Ev $ftp_proxy .
1353 .It Cm http_proxy
1354 Defaults to
1355 .Ev $http_proxy .
1356 .It Cm no_proxy
1357 Defaults to
1358 .Ev $no_proxy .
1359 .It Cm pager
1360 Defaults to
1361 .Ev $PAGER .
1362 .It Cm prompt
1363 Defaults to
1364 .Ev $FTPPROMPT .
1365 .It Cm rprompt
1366 Defaults to
1367 .Ev $FTPRPROMPT .
1368 .El
1369 .It Ic site Ar arg1 arg2 ...
1370 The arguments specified are sent, verbatim, to the remote
1371 .Tn FTP
1372 server as a
1373 .Dv SITE
1374 command.
1375 .It Ic size Ar remote-file
1376 Return size of
1377 .Ar remote-file
1378 on remote machine.
1379 .It Ic sndbuf Ar size
1380 Set the size of the socket send buffer to
1381 .Ar size .
1382 .It Ic status
1383 Show the current status of
1384 .Nm ftp .
1385 .It Ic struct Ar struct-name
1386 Set the file transfer
1387 .Ar structure
1388 to
1389 .Ar struct-name .
1390 The default (and only supported)
1391 structure is
1392 .Dq file .
1393 .It Ic sunique
1394 Toggle storing of files on remote machine under unique file names.
1395 The remote
1396 .Tn FTP
1397 server must support
1398 .Tn FTP
1399 protocol
1400 .Dv STOU
1401 command for
1402 successful completion.
1403 The remote server will report unique name.
1404 Default value is off.
1405 .It Ic system
1406 Show the type of operating system running on the remote machine.
1407 .It Ic tenex
1408 Set the file transfer type to that needed to
1409 talk to
1410 .Tn TENEX
1411 machines.
1412 .It Ic throttle
1413 A synonym for
1414 .Ic rate .
1415 .It Ic trace
1416 Toggle packet tracing.
1417 .It Ic type Op Ar type-name
1418 Set the file transfer
1419 .Ic type
1420 to
1421 .Ar type-name .
1422 If no type is specified, the current type
1423 is printed.
1424 The default type is network
1425 .Tn ASCII .
1426 .It Ic umask Op Ar newmask
1427 Set the default umask on the remote server to
1428 .Ar newmask .
1429 If
1430 .Ar newmask
1431 is omitted, the current umask is printed.
1432 .It Ic unset Ar option
1433 Unset
1434 .Ar option .
1435 Refer to
1436 .Ic set
1437 for more information.
1438 .It Ic usage Ar command
1439 Print the usage message for
1440 .Ar command .
1441 .It Xo
1442 .Ic user Ar user-name
1443 .Op Ar password Op Ar account
1444 .Xc
1445 Identify yourself to the remote
1446 .Tn FTP
1447 server.
1448 If the
1449 .Ar password
1450 is not specified and the server requires it,
1451 .Nm
1452 will prompt the user for it (after disabling local echo).
1453 If an
1454 .Ar account
1455 field is not specified, and the
1456 .Tn FTP
1457 server
1458 requires it, the user will be prompted for it.
1459 If an
1460 .Ar account
1461 field is specified, an account command will
1462 be relayed to the remote server after the login sequence
1463 is completed if the remote server did not require it
1464 for logging in.
1465 Unless
1466 .Nm
1467 is invoked with
1468 .Dq auto-login
1469 disabled, this process is done automatically on initial connection to the
1470 .Tn FTP
1471 server.
1472 .It Ic verbose
1473 Toggle verbose mode.
1474 In verbose mode, all responses from
1475 the
1476 .Tn FTP
1477 server are displayed to the user.
1478 In addition,
1479 if verbose is on, when a file transfer completes, statistics
1480 regarding the efficiency of the transfer are reported.
1481 By default,
1482 verbose is on.
1483 .It Ic xferbuf Ar size
1484 Set the size of the socket send and receive buffers to
1485 .Ar size .
1486 .It Ic \&? Op Ar command
1487 A synonym for
1488 .Ic help .
1489 .El
1490 .Pp
1491 Command arguments which have embedded spaces may be quoted with
1492 quote
1493 .Sq \&"
1494 marks.
1495 .Pp
1496 Commands which toggle settings can take an explicit
1497 .Ic on
1498 or
1499 .Ic off
1500 argument to force the setting appropriately.
1501 .Pp
1502 Commands which take a byte count as an argument
1503 (e.g.,
1504 .Ic hash ,
1505 .Ic rate ,
1506 and
1507 .Ic xferbuf )
1508 support an optional suffix on the argument which changes the
1509 interpretation of the argument.
1510 Supported suffixes are:
1511 .Bl -tag -width 3n -offset indent -compact
1512 .It Li b
1513 Causes no modification.
1514 (Optional)
1515 .It Li k
1516 Kilo; multiply the argument by 1024
1517 .It Li m
1518 Mega; multiply the argument by 1048576
1519 .It Li g
1520 Giga; multiply the argument by 1073741824
1521 .El
1522 .Pp
1523 If
1524 .Nm
1525 receives a
1526 .Dv SIGINFO
1527 (see the
1528 .Dq status
1529 argument of
1530 .Xr stty 1 )
1531 or
1532 .Dv SIGQUIT
1533 signal whilst a transfer is in progress, the current transfer rate
1534 statistics will be written to the standard error output, in the
1535 same format as the standard completion message.
1536 .Sh AUTO-FETCHING FILES
1537 In addition to standard commands, this version of
1538 .Nm
1539 supports an auto-fetch feature.
1540 To enable auto-fetch, simply pass the list of hostnames/files
1541 on the command line.
1542 .Pp
1543 The following formats are valid syntax for an auto-fetch element:
1544 .Bl -tag -width "FOO "
1545 .\" [user@]host:[path][/]
1546 .It Xo
1547 .Sm off
1548 .Op Ar user Li \&@
1549 .Ar host Li \&:
1550 .Op Ar path
1551 .Op Li /
1552 .Sm on
1553 .Xc
1554 .Dq Classic
1555 .Tn FTP
1556 format.
1557 .Pp
1558 If
1559 .Ar path
1560 contains a glob character and globbing is enabled,
1561 (see
1562 .Ic glob ) ,
1563 then the equivalent of
1564 .Ql mget path
1565 is performed.
1566 .Pp
1567 If the directory component of
1568 .Ar path
1569 contains no globbing characters,
1570 it is stored locally with the name basename (see
1571 .Xr basename 1 )
1572 of
1573 .Ic path ,
1574 in the current directory.
1575 Otherwise, the full remote name is used as the local name,
1576 relative to the local root directory.
1577 .\" ftp://[user[:password]@]host[:port]/path[/][;type=X]
1578 .It Xo
1579 .Sm off
1580 .Li ftp://
1581 .Oo Ar user
1582 .Op Li \&: Ar password
1583 .Li \&@ Oc
1584 .Ar host Oo Li \&: Ar port Oc
1585 .Li / Ar path
1586 .Op Li /
1587 .Op Li ;type= Ar X
1588 .Sm on
1589 .Xc
1590 An
1591 .Tn FTP
1592 URL, retrieved using the
1593 .Tn FTP
1594 protocol if
1595 .Ic "set ftp_proxy"
1596 isn't defined.
1597 Otherwise, transfer the URL using
1598 .Tn HTTP
1599 via the proxy defined in
1600 .Ic "set ftp_proxy" .
1601 If
1602 .Ic "set ftp_proxy"
1603 isn't defined and
1604 .Ar user
1605 is given, login as
1606 .Ar user .
1607 In this case, use
1608 .Ar password
1609 if supplied, otherwise prompt the user for one.
1610 .Pp
1611 If a suffix of
1612 .Sq ;type=A
1613 or
1614 .Sq ;type=I
1615 is supplied, then the transfer type will take place as
1616 ascii or binary (respectively).
1617 The default transfer type is binary.
1618 .Pp
1619 In order to be compliant with
1620 .Li RFC 1738 ,
1621 .Nm
1622 interprets the
1623 .Ar path
1624 part of an
1625 .Dq ftp://
1626 auto-fetch URL as follows:
1627 .Bl -bullet
1628 .It
1629 The
1630 .Sq Li /
1631 immediately after the
1632 .Ar host Ns Oo Li \&: Ns Ar port Oc
1633 is interpreted as a separator before the
1634 .Ar path ,
1635 and not as part of the
1636 .Ar path
1637 itself.
1638 .It
1639 The
1640 .Ar path
1641 is interpreted as a
1642 .So Li / Sc Ns -separated
1643 list of name components.
1644 For all but the last such component,
1645 .Nm
1646 performs the equivalent of a
1647 .Ic cd
1648 command.
1649 For the last path component,
1650 .Nm
1651 performs the equivalent of a
1652 .Ic get
1653 command.
1654 .It
1655 Empty name components,
1656 which result from
1657 .Sq Li //
1658 within the
1659 .Ar path ,
1660 or from an extra
1661 .Sq Li /
1662 at the beginning of the
1663 .Ar path ,
1664 will cause the equivalent of a
1665 .Ic cd
1666 command without a directory name.
1667 This is unlikely to be useful.
1668 .It
1669 Any
1670 .Sq Li \&% Ns Ar XX
1671 codes
1672 (per
1673 .Li RFC 1738 )
1674 within the path components are decoded, with
1675 .Ar XX
1676 representing a character code in hexadecimal.
1677 This decoding takes place after the
1678 .Ar path
1679 has been split into components,
1680 but before each component is used in the equivalent of a
1681 .Ic cd
1682 or
1683 .Ic get
1684 command.
1685 Some often-used codes are
1686 .Sq Li \&%2F
1687 (which represents
1688 .Sq Li / )
1689 and
1690 .Sq Li \&%7E
1691 (which represents
1692 .Sq Li ~ ) .
1693 .El
1694 .Pp
1695 The above interpretation has the following consequences:
1696 .Bl -bullet
1697 .It
1698 The path is interpreted relative to the
1699 default login directory of the specified user or of the
1700 .Sq anonymous
1701 user.
1702 If the
1703 .Pa /
1704 directory is required, use a leading path of
1705 .Dq %2F .
1706 If a user's home directory is required (and the remote server supports
1707 the syntax), use a leading path of
1708 .Dq %7Euser/ .
1709 For example, to retrieve
1710 .Pa /etc/motd
1711 from
1712 .Sq localhost
1713 as the user
1714 .Sq myname
1715 with the password
1716 .Sq mypass ,
1717 use
1718 .Dq ftp://myname:mypass@localhost/%2fetc/motd
1719 .It
1720 The exact
1721 .Ic cd
1722 and
1723 .Ic get
1724 commands can be controlled by careful choice of
1725 where to use
1726 .Sq /
1727 and where to use
1728 .Sq %2F
1729 (or
1730 .Sq %2f ) .
1731 For example, the following URLs correspond to the
1732 equivalents of the indicated commands:
1733 .Bl -tag -width "ftp://host/%2Fdir1%2Fdir2%2Ffile"
1734 .It ftp://host/dir1/dir2/file
1735 .Dq "cd dir1" ,
1736 .Dq "cd dir2" ,
1737 .Dq "get file" .
1738 .It ftp://host/%2Fdir1/dir2/file
1739 .Dq "cd /dir1" ,
1740 .Dq "cd dir2" ,
1741 .Dq "get file" .
1742 .It ftp://host/dir1%2Fdir2/file
1743 .Dq "cd dir1/dir2" ,
1744 .Dq "get file" .
1745 .It ftp://host/%2Fdir1%2Fdir2/file
1746 .Dq "cd /dir1/dir2" ,
1747 .Dq "get file" .
1748 .It ftp://host/dir1%2Fdir2%2Ffile
1749 .Dq "get dir1/dir2/file" .
1750 .It ftp://host/%2Fdir1%2Fdir2%2Ffile
1751 .Dq "get /dir1/dir2/file" .
1752 .El
1753 .It
1754 You must have appropriate access permission for each of the
1755 intermediate directories that is used in the equivalent of a
1756 .Ic cd
1757 command.
1758 .El
1759 .\" http://[user[:password]@]host[:port]/path
1760 .It Xo
1761 .Sm off
1762 .Li http://
1763 .Oo Ar user
1764 .Op Li \&: Ar password
1765 .Li \&@ Oc
1766 .Ar host Oo Li \&: Ar port Oc
1767 .Li / Ar path
1768 .Sm on
1769 .Xc
1770 An
1771 .Tn HTTP
1772 URL, retrieved using the
1773 .Tn HTTP
1774 protocol.
1775 If
1776 .Ic "set http_proxy"
1777 is defined, it is used as a URL to an
1778 .Tn HTTP
1779 proxy server.
1780 If
1781 .Tn HTTP
1782 authorization is required to retrieve
1783 .Ar path ,
1784 and
1785 .Sq user
1786 (and optionally
1787 .Sq password )
1788 is in the URL, use them for the first attempt to authenticate.
1789 .\" file:///path
1790 .It Xo
1791 .Sm off
1792 .Li file:/// Ar path
1793 .Sm on
1794 .Xc
1795 A local URL, copied from
1796 .Pa / Ns Ar path
1797 on the local host.
1798 .El
1799 .Pp
1800 Unless noted otherwise above, and
1801 .Fl o Ar output
1802 is not given, the file is stored in the current directory as the
1803 .Xr basename 1
1804 of
1805 .Ar path .
1806 Note that if a
1807 .Tn HTTP
1808 redirect is received, the fetch is retried using the new target URL
1809 supplied by the server, with a corresponding new
1810 .Ar path .
1811 Using an explicit
1812 .Fl o Ar output
1813 is recommended, to avoid writing to unexpected file names.
1814 .Pp
1815 If a classic format or an
1816 .Tn FTP
1817 URL format has a trailing
1818 .Sq /
1819 or an empty
1820 .Ar path
1821 component, then
1822 .Nm
1823 will connect to the site and
1824 .Ic cd
1825 to the directory given as the path, and leave the user in interactive
1826 mode ready for further input.
1827 This will not work if
1828 .Ic "set ftp_proxy"
1829 is being used.
1830 .Pp
1831 Direct
1832 .Tn HTTP
1833 transfers use HTTP 1.1.
1834 Proxied
1835 .Tn FTP
1836 and
1837 .Tn HTTP
1838 transfers use HTTP 1.0.
1839 .Pp
1840 If
1841 .Fl R
1842 is given, all auto-fetches that don't go via the
1843 .Tn FTP
1844 or
1845 .Tn HTTP
1846 proxies will be restarted.
1847 For
1848 .Tn FTP ,
1849 this is implemented by using
1850 .Nm reget
1851 instead of
1852 .Nm get .
1853 For
1854 .Tn HTTP ,
1855 this is implemented by using the
1856 .Sq "Range: bytes="
1857 .Tn "HTTP/1.1"
1858 directive.
1859 .Pp
1860 If WWW or proxy WWW authentication is required, you will be prompted
1861 to enter a username and password to authenticate with.
1862 .Pp
1863 When specifying IPv6 numeric addresses in a URL, you need to
1864 surround the address in square brackets.
1865 E.g.:
1866 .Dq ftp://[::1]:21/ .
1867 This is because colons are used in IPv6 numeric address as well as
1868 being the separator for the port number.
1869 .Sh ABORTING A FILE TRANSFER
1870 To abort a file transfer, use the terminal interrupt key
1871 (usually Ctrl-C).
1872 Sending transfers will be immediately halted.
1873 Receiving transfers will be halted by sending an
1874 .Tn FTP
1875 protocol
1876 .Dv ABOR
1877 command to the remote server, and discarding any further data received.
1878 The speed at which this is accomplished depends upon the remote
1879 server's support for
1880 .Dv ABOR
1881 processing.
1882 If the remote server does not support the
1883 .Dv ABOR
1884 command, the prompt will not appear until the remote server has completed
1885 sending the requested file.
1886 .Pp
1887 If the terminal interrupt key sequence is used whilst
1888 .Nm
1889 is awaiting a reply from the remote server for the ABOR processing,
1890 then the connection will be closed.
1891 This is different from the traditional behaviour (which ignores the
1892 terminal interrupt during this phase), but is considered more useful.
1893 .Sh FILE NAMING CONVENTIONS
1894 Files specified as arguments to
1895 .Nm
1896 commands are processed according to the following rules.
1897 .Bl -enum
1898 .It
1899 If the file name
1900 .Sq Fl
1901 is specified, the
1902 .Ar stdin
1903 (for reading) or
1904 .Ar stdout
1905 (for writing) is used.
1906 .It
1907 If the first character of the file name is
1908 .Sq \&| ,
1909 the
1910 remainder of the argument is interpreted as a shell command.
1911 .Nm
1912 then forks a shell, using
1913 .Xr popen 3
1914 with the argument supplied, and reads (writes) from the stdout
1915 (stdin).
1916 If the shell command includes spaces, the argument
1917 must be quoted; e.g.
1918 .Dq Qq Li \&| ls\ \-lt .
1919 A particularly
1920 useful example of this mechanism is:
1921 .Dq Li dir \&"\&" \&|more .
1922 .It
1923 Failing the above checks, if
1924 .Dq globbing
1925 is enabled, local file names are expanded according to the rules
1926 used in the
1927 .Xr csh  1  ;
1928 see the
1929 .Ic glob
1930 command.
1931 If the
1932 .Nm
1933 command expects a single local file (e.g.
1934 .Ic put  ) ,
1935 only the first filename generated by the "globbing" operation is used.
1936 .It
1937 For
1938 .Ic mget
1939 commands and
1940 .Ic get
1941 commands with unspecified local file names, the local filename is
1942 the remote filename, which may be altered by a
1943 .Ic case  ,
1944 .Ic ntrans ,
1945 or
1946 .Ic nmap
1947 setting.
1948 The resulting filename may then be altered if
1949 .Ic runique
1950 is on.
1951 .It
1952 For
1953 .Ic mput
1954 commands and
1955 .Ic put
1956 commands with unspecified remote file names, the remote filename is
1957 the local filename, which may be altered by a
1958 .Ic ntrans
1959 or
1960 .Ic nmap
1961 setting.
1962 The resulting filename may then be altered by the remote server if
1963 .Ic sunique
1964 is on.
1965 .El
1966 .Sh FILE TRANSFER PARAMETERS
1967 The
1968 .Tn FTP
1969 specification specifies many parameters which may affect a file transfer.
1970 The
1971 .Ic type
1972 may be one of
1973 .Dq ascii ,
1974 .Dq image
1975 (binary),
1976 .Dq ebcdic ,
1977 and
1978 .Dq local byte size
1979 (for
1980 .Tn PDP Ns -10's
1981 and
1982 .Tn PDP Ns -20's
1983 mostly).
1984 .Nm
1985 supports the ascii and image types of file transfer,
1986 plus local byte size 8 for
1987 .Ic tenex
1988 mode transfers.
1989 .Pp
1990 .Nm
1991 supports only the default values for the remaining
1992 file transfer parameters:
1993 .Ic mode ,
1994 .Ic form ,
1995 and
1996 .Ic struct .
1997 .Sh THE .netrc FILE
1998 The
1999 .Pa .netrc
2000 file contains login and initialization information
2001 used by the auto-login process.
2002 It resides in the user's home directory,
2003 unless overridden with the
2004 .Fl N Ar netrc
2005 option, or specified in the
2006 .Ev NETRC
2007 environment variable.
2008 The following tokens are recognized; they may be separated by spaces,
2009 tabs, or new-lines:
2010 .Bl -tag -width password
2011 .It Ic machine Ar name
2012 Identify a remote machine
2013 .Ar name .
2014 The auto-login process searches the
2015 .Pa .netrc
2016 file for a
2017 .Ic machine
2018 token that matches the remote machine specified on the
2019 .Nm
2020 command line or as an
2021 .Ic open
2022 command argument.
2023 Once a match is made, the subsequent
2024 .Pa .netrc
2025 tokens are processed,
2026 stopping when the end of file is reached or another
2027 .Ic machine
2028 or a
2029 .Ic default
2030 token is encountered.
2031 .It Ic default
2032 This is the same as
2033 .Ic machine
2034 .Ar name
2035 except that
2036 .Ic default
2037 matches any name.
2038 There can be only one
2039 .Ic default
2040 token, and it must be after all
2041 .Ic machine
2042 tokens.
2043 This is normally used as:
2044 .Pp
2045 .Dl default login anonymous password user@site
2046 .Pp
2047 thereby giving the user an automatic anonymous
2048 .Tn FTP
2049 login to
2050 machines not specified in
2051 .Pa .netrc .
2052 This can be overridden
2053 by using the
2054 .Fl n
2055 flag to disable auto-login.
2056 .It Ic login Ar name
2057 Identify a user on the remote machine.
2058 If this token is present, the auto-login process will initiate
2059 a login using the specified
2060 .Ar name .
2061 .It Ic password Ar string
2062 Supply a password.
2063 If this token is present, the auto-login process will supply the
2064 specified string if the remote server requires a password as part
2065 of the login process.
2066 Note that if this token is present in the
2067 .Pa .netrc
2068 file for any user other
2069 than
2070 .Ar anonymous  ,
2071 .Nm
2072 will abort the auto-login process if the
2073 .Pa .netrc
2074 is readable by
2075 anyone besides the user.
2076 .It Ic account Ar string
2077 Supply an additional account password.
2078 If this token is present, the auto-login process will supply the
2079 specified string if the remote server requires an additional
2080 account password, or the auto-login process will initiate an
2081 .Dv ACCT
2082 command if it does not.
2083 .It Ic macdef Ar name
2084 Define a macro.
2085 This token functions like the
2086 .Nm
2087 .Ic macdef
2088 command functions.
2089 A macro is defined with the specified name; its contents begin with the
2090 next
2091 .Pa .netrc
2092 line and continue until a blank line (consecutive new-line
2093 characters) is encountered.
2094 Like the other tokens in the
2095 .Pa .netrc
2096 file, a
2097 .Ic macdef
2098 is applicable only to the
2099 .Ic machine
2100 definition preceding it.
2101 A
2102 .Ic macdef
2103 entry cannot be utilized by multiple
2104 .Ic machine
2105 definitions; rather, it must be defined following each
2106 .Ic machine
2107 it is intended to be used with.
2108 If a macro named
2109 .Ic init
2110 is defined, it is automatically executed as the last step in the
2111 auto-login process.
2112 For example,
2113 .Bd -literal -offset indent
2114 default
2115 macdef init
2116 epsv4 off
2117 .Ed
2118 .Pp
2119 followed by a blank line.
2120 .El
2121 .Sh COMMAND LINE EDITING
2122 .Nm
2123 supports interactive command line editing, via the
2124 .Xr editline 3
2125 library.
2126 It is enabled with the
2127 .Ic edit
2128 command, and is enabled by default if input is from a tty.
2129 Previous lines can be recalled and edited with the arrow keys,
2130 and other GNU Emacs-style editing keys may be used as well.
2131 .Pp
2132 The
2133 .Xr editline 3
2134 library is configured with a
2135 .Pa .editrc
2136 file - refer to
2137 .Xr editrc 5
2138 for more information.
2139 .Pp
2140 An extra key binding is available to
2141 .Nm
2142 to provide context sensitive command and filename completion
2143 (including remote file completion).
2144 To use this, bind a key to the
2145 .Xr editline 3
2146 command
2147 .Ic ftp-complete .
2148 By default, this is bound to the TAB key.
2149 .Sh COMMAND LINE PROMPT
2150 By default,
2151 .Nm
2152 displays a command line prompt of
2153 .Dq "ftp\*[Gt] "
2154 to the user.
2155 This can be changed with the
2156 .Ic "set prompt"
2157 command.
2158 .Pp
2159 A prompt can be displayed on the right side of the screen (after the
2160 command input) with the
2161 .Ic "set rprompt"
2162 command.
2163 .Pp
2164 The following formatting sequences are replaced by the given
2165 information:
2166 .Bl -tag -width "%% " -offset indent
2167 .It Li \&%/
2168 The current remote working directory.
2169 .\" %c[[0]n], %.[[0]n]
2170 .It Xo
2171 .Sm off
2172 .Li \&%c
2173 .Op Oo Li 0 Oc Ar n Ns ,
2174 .Li \&%.
2175 .Op Oo Li 0 Oc Ar n
2176 .Sm on
2177 .Xc
2178 The trailing component of the current remote working directory, or
2179 .Em n
2180 trailing components if a digit
2181 .Em n
2182 is given.
2183 If
2184 .Em n
2185 begins with
2186 .Sq 0 ,
2187 the number of skipped components precede the trailing component(s) in
2188 the format
2189 .\" ``/<number>trailing''
2190 .Do
2191 .Sm off
2192 .Li / Li \*[Lt] Va number Li \*[Gt]
2193 .Va trailing
2194 .Sm on
2195 .Dc
2196 (for
2197 .Sq \&%c )
2198 or
2199 .\" ``...trailing''
2200 .Dq Li \&... Ns Va trailing
2201 (for
2202 .Sq \&%. ) .
2203 .It Li \&%M
2204 The remote host name.
2205 .It Li \&%m
2206 The remote host name, up to the first
2207 .Sq \&. .
2208 .It Li \&%n
2209 The remote user name.
2210 .It Li \&%%
2211 A single
2212 .Sq % .
2213 .El
2214 .Sh ENVIRONMENT
2215 .Nm
2216 uses the following environment variables.
2217 .Bl -tag -width "FTPSERVERPORT"
2218 .It Ev FTPANONPASS
2219 Password to send in an anonymous
2220 .Tn FTP
2221 transfer.
2222 Defaults to
2223 .Dq Li `whoami`@ .
2224 .It Ev FTPMODE
2225 Overrides the default operation mode.
2226 Support values are:
2227 .Bl -tag -width "passive"
2228 .It Cm active
2229 active mode
2230 .Tn FTP
2231 only
2232 .It Cm auto
2233 automatic determination of passive or active (this is the default)
2234 .It Cm gate
2235 gate-ftp mode
2236 .It Cm passive
2237 passive mode
2238 .Tn FTP
2239 only
2240 .El
2241 .It Ev FTPPROMPT
2242 Command-line prompt to use.
2243 Defaults to
2244 .Dq "ftp\*[Gt] " .
2245 Refer to
2246 .Sx COMMAND LINE PROMPT
2247 for more information.
2248 .It Ev FTPRPROMPT
2249 Command-line right side prompt to use.
2250 Defaults to
2251 .Dq "" .
2252 Refer to
2253 .Sx COMMAND LINE PROMPT
2254 for more information.
2255 .It Ev FTPSERVER
2256 Host to use as gate-ftp server when
2257 .Ic gate
2258 is enabled.
2259 .It Ev FTPSERVERPORT
2260 Port to use when connecting to gate-ftp server when
2261 .Ic gate
2262 is enabled.
2263 Default is port returned by a
2264 .Fn getservbyname
2265 lookup of
2266 .Dq ftpgate/tcp .
2267 .It Ev FTPUSERAGENT
2268 The value to send for the
2269 .Tn HTTP
2270 User-Agent
2271 header.
2272 .It Ev HOME
2273 For default location of a
2274 .Pa .netrc
2275 file, if one exists.
2276 .It Ev NETRC
2277 An alternate location of the
2278 .Pa .netrc
2279 file.
2280 .It Ev PAGER
2281 Used by various commands to display files.
2282 Defaults to
2283 .Xr more 1
2284 if empty or not set.
2285 .It Ev SHELL
2286 For default shell.
2287 .It Ev ftp_proxy
2288 URL of
2289 .Tn FTP
2290 proxy to use when making
2291 .Tn FTP
2292 URL requests
2293 (if not defined, use the standard
2294 .Tn FTP
2295 protocol).
2296 .Pp
2297 See
2298 .Ev http_proxy
2299 for further notes about proxy use.
2300 .It Ev http_proxy
2301 URL of
2302 .Tn HTTP
2303 proxy to use when making
2304 .Tn HTTP
2305 URL requests.
2306 If proxy authentication is required and there is a username and
2307 password in this URL, they will automatically be used in the first
2308 attempt to authenticate to the proxy.
2309 .Pp
2310 If
2311 .Dq unsafe
2312 URL characters are required in the username or password
2313 (for example
2314 .Sq @
2315 or
2316 .Sq / ) ,
2317 encode them with
2318 .Li RFC 1738
2319 .Sq Li \&% Ns Ar XX
2320 encoding.
2321 .Pp
2322 Note that the use of a username and password in
2323 .Ev ftp_proxy
2324 and
2325 .Ev http_proxy
2326 may be incompatible with other programs that use it
2327 (such as
2328 .Xr lynx 1 ) .
2329 .Pp
2330 .Em NOTE :
2331 this is not used for interactive sessions, only for command-line
2332 fetches.
2333 .It Ev no_proxy
2334 A space or comma separated list of hosts (or domains) for which
2335 proxying is not to be used.
2336 Each entry may have an optional trailing ":port", which restricts
2337 the matching to connections to that port.
2338 .El
2339 .Sh EXTENDED PASSIVE MODE AND FIREWALLS
2340 Some firewall configurations do not allow
2341 .Nm
2342 to use extended passive mode.
2343 If you find that even a simple
2344 .Ic ls
2345 appears to hang after printing a message such as this:
2346 .Pp
2347 .Dl 229 Entering Extended Passive Mode (|||58551|)
2348 .Pp
2349 then you will need to disable extended passive mode with
2350 .Ic epsv4 off .
2351 See the above section
2352 .Sx The .netrc File
2353 for an example of how to make this automatic.
2354 .Sh SEE ALSO
2355 .Xr getservbyname 3 ,
2356 .Xr editrc 5 ,
2357 .Xr services 5 ,
2358 .Xr ftpd 8
2359 .Sh STANDARDS
2360 .Nm
2361 attempts to be compliant with
2362 .Li RFC 959 ,
2363 .Li RFC 1123 ,
2364 .Li RFC 1738 ,
2365 .Li RFC 2068 ,
2366 .Li RFC 2389 ,
2367 .Li RFC 2428 ,
2368 .Li RFC 2732 ,
2369 and
2370 .Cm draft-ietf-ftpext-mlst-11 .
2371 .Sh HISTORY
2372 The
2373 .Nm
2374 command appeared in
2375 .Bx 4.2 .
2376 .Pp
2377 Various features such as command line editing, context sensitive
2378 command and file completion, dynamic progress bar, automatic
2379 fetching of files and URLs, modification time preservation,
2380 transfer rate throttling, configurable command line prompt,
2381 and other enhancements over the standard
2382 .Bx
2383 .Nm
2384 were implemented in
2385 .Nx 1.3
2386 and later releases
2387 by
2388 .An Luke Mewburn
2389 .Aq lukem@NetBSD.org .
2390 .Pp
2391 IPv6 support was added by the WIDE/KAME project
2392 (but may not be present in all non-NetBSD versions of this program, depending
2393 if the operating system supports IPv6 in a similar manner to KAME).
2394 .Sh BUGS
2395 Correct execution of many commands depends upon proper behavior
2396 by the remote server.
2397 .Pp
2398 An error in the treatment of carriage returns
2399 in the
2400 .Bx 4.2
2401 ascii-mode transfer code
2402 has been corrected.
2403 This correction may result in incorrect transfers of binary files
2404 to and from
2405 .Bx 4.2
2406 servers using the ascii type.
2407 Avoid this problem by using the binary image type.
2408 .Pp
2409 .Nm
2410 assumes that all IPv4 mapped addresses
2411 .Po
2412 IPv6 addresses with a form like
2413 .Li ::ffff:10.1.1.1
2414 .Pc
2415 indicate IPv4 destinations which can be handled by
2416 .Dv AF_INET
2417 sockets.
2418 However, in certain IPv6 network configurations, this assumption is not true.
2419 In such an environment, IPv4 mapped addresses must be passed to
2420 .Dv AF_INET6
2421 sockets directly.
2422 For example, if your site uses a SIIT translator for IPv6-to-IPv4 translation,
2423 .Nm
2424 is unable to support your configuration.