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