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