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