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