Merge from vendor branch TEXINFO:
[dragonfly.git] / usr.bin / ftp / ftp.1
1 .\" $FreeBSD: src/usr.bin/ftp/ftp.1,v 1.15.2.7 2002/08/27 09:55:08 yar Exp $
2 .\" $DragonFly: src/usr.bin/ftp/Attic/ftp.1,v 1.4 2005/08/05 22:35:11 swildner Exp $
3 .\"     $NetBSD: ftp.1,v 1.21 1997/06/10 21:59:58 lukem Exp $
4 .\"
5 .\" Copyright (c) 1985, 1989, 1990, 1993
6 .\"     The Regents of the University of California.  All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)ftp.1       8.3 (Berkeley) 10/9/94
37 .\"
38 .Dd January 27, 2000
39 .Dt FTP 1
40 .Os
41 .Sh NAME
42 .Nm ftp ,
43 .Nm pftp ,
44 .Nm gate-ftp
45 .Nd
46 .Tn ARPANET
47 file transfer program
48 .Sh SYNOPSIS
49 .Nm
50 .Op Fl 46adeginptUvV
51 .Op Fl P Ar port
52 .Op Fl s Ar src_addr
53 .Op Ar host Op Ar port
54 .Nm
55 ftp://[\fIuser\fR:\fIpassword\fR@]\fIhost\fR[:\fIport\fR]/\fIfile\fR[/]
56 .Nm
57 http://\fIhost\fR[:\fIport\fR]/\fIfile\fR
58 .Nm
59 \fIhost\fR:[/\fIpath\fR/]\fIfile\fR[/]
60 .Sh DESCRIPTION
61 .Nm
62 is the user interface to the
63 .Tn ARPANET
64 standard File Transfer Protocol.
65 The program allows a user to transfer files to and from a
66 remote network site.
67 The version supports IPv6 (Internet protocol version 6), as well as IPv4.
68 .Pp
69 The latter three usage formats will fetch a file using either the
70 HTTP or FTP protocols into the current directory.
71 This is ideal for scripts.
72 Refer to
73 .Sx AUTO-FETCHING FILES
74 below for more information.
75 .Pp
76 Options may be specified at the command line, or to the
77 command interpreter.
78 .Bl -tag -width Fl
79 .It Fl 4
80 Forces
81 .Nm
82 to use IPv4 addresses only.
83 .It Fl 6
84 Forces
85 .Nm
86 to use IPv6 addresses only.
87 .It Fl a
88 Causes
89 .Nm
90 to bypass normal login procedure, and use an anonymous login instead.
91 .It Fl d
92 Enables debugging.
93 .It Fl e
94 Disables command line editing.
95 .It Fl g
96 Disables file name globbing.
97 .It Fl i
98 Turns off interactive prompting during
99 multiple file transfers.
100 .It Fl n
101 Restrains
102 .Nm
103 from attempting
104 .Dq auto-login
105 upon initial connection.
106 If auto-login is enabled,
107 .Nm
108 will check the
109 .Pa .netrc
110 (see below) file in the user's home directory for an entry describing
111 an account on the remote machine.
112 If no entry exists,
113 .Nm
114 will prompt for the remote machine login name (default is the user
115 identity on the local machine), and, if necessary, prompt for a password
116 and an account with which to login.
117 .It Fl p
118 Enables passive mode operation for use behind connection filtering firewalls.
119 Using the
120 .Nm pftp
121 command has the same effect.
122 .It Fl P Ar port
123 Sets the port number to
124 .Ar port .
125 .It Fl s Ar src_addr
126 Sets the local IP address for all connections to
127 .Ar src_addr ,
128 which can be an IP address or a host name.
129 .It Fl t
130 Enables packet tracing.
131 .It Fl U
132 Disable data port range restrictions.
133 .It Fl v
134 Enable verbose mode.
135 This is the default if input is from a terminal.
136 Forces
137 .Nm
138 to show all responses from the remote server, as well
139 as report on data transfer statistics.
140 .It Fl V
141 Disable verbose mode, overriding the default of enabled when input
142 is from a terminal.
143 .El
144 .Pp
145 The client host with which
146 .Nm
147 is to communicate may be specified on the command line.
148 If this is done,
149 .Nm
150 will immediately attempt to establish a connection to an
151 .Tn FTP
152 server on that host; otherwise,
153 .Nm
154 will enter its command interpreter and await instructions
155 from the user.
156 When
157 .Nm
158 is awaiting commands from the user the prompt
159 .Ql ftp>
160 is provided to the user.
161 The following commands are recognized
162 by
163 .Nm :
164 .Bl -tag -width Fl
165 .It Ic \&! Op Ar command Op Ar args
166 Invoke an interactive shell on the local machine.
167 If there are arguments, the first is taken to be a command to execute
168 directly, with the rest of the arguments as its arguments.
169 .It Ic \&$ Ar macro-name Op Ar args
170 Execute the macro
171 .Ar macro-name
172 that was defined with the
173 .Ic macdef
174 command.
175 Arguments are passed to the macro unglobbed.
176 .It Ic account Op Ar passwd
177 Supply a supplemental password required by a remote system for access
178 to resources once a login has been successfully completed.
179 If no argument is included, the user will be prompted for an account
180 password in a non-echoing input mode.
181 .It Ic append Ar local-file Op Ar remote-file
182 Append a local file to a file on the remote machine.
183 If
184 .Ar remote-file
185 is left unspecified, the local file name is used in naming the
186 remote file after being altered by any
187 .Ic ntrans
188 or
189 .Ic nmap
190 setting.
191 File transfer uses the current settings for
192 .Ic type  ,
193 .Ic format ,
194 .Ic mode
195 and
196 .Ic structure .
197 .It Ic ascii
198 Set the file transfer
199 .Ic type
200 to network
201 .Tn ASCII .
202 This is the default type.
203 .It Ic bell
204 Arrange that a bell be sounded after each file transfer
205 command is completed.
206 .It Ic binary
207 Set the file transfer
208 .Ic type
209 to support binary image transfer.
210 .It Ic bye
211 Terminate the
212 .Tn FTP
213 session with the remote server
214 and exit
215 .Nm .
216 An end of file will also terminate the session and exit.
217 .It Ic case
218 Toggle remote computer file name case mapping during
219 .Ic mget
220 commands.
221 When
222 .Ic case
223 is on (default is off), remote computer file names with all letters in
224 upper case are written in the local directory with the letters mapped
225 to lower case.
226 .It Ic \&cd Ar remote-directory
227 Change the working directory on the remote machine
228 to
229 .Ar remote-directory .
230 .It Ic cdup
231 Change the remote machine working directory to the parent of the
232 current remote machine working directory.
233 .It Ic chmod Ar mode file-name
234 Change the permission modes of the file
235 .Ar file-name
236 on the remote
237 system to
238 .Ar mode .
239 .It Ic close
240 Terminate the
241 .Tn FTP
242 session with the remote server, and
243 return to the command interpreter.
244 Any defined macros are erased.
245 .It Ic \&cr
246 Toggle carriage return stripping during
247 ascii type file retrieval.
248 Records are denoted by a carriage return/linefeed sequence
249 during ascii type file transfer.
250 When
251 .Ic \&cr
252 is on (the default), carriage returns are stripped from this
253 sequence to conform with the
254 .Ux
255 single linefeed record
256 delimiter.
257 Records on
258 .Pf non\- Ns Ux
259 remote systems may contain single linefeeds;
260 when an ascii type transfer is made, these linefeeds may be
261 distinguished from a record delimiter only when
262 .Ic \&cr
263 is off.
264 .It Ic delete Ar remote-file
265 Delete the file
266 .Ar remote-file
267 on the remote machine.
268 .It Ic debug Op Ar debug-value
269 Toggle debugging mode.
270 If an optional
271 .Ar debug-value
272 is specified, it is used to set the debugging level.
273 When debugging is on,
274 .Nm
275 prints each command sent to the remote machine, preceded
276 by the string
277 .Ql \-\->
278 .It Ic dir Op Ar remote-directory Op Ar local-file
279 Print a listing of the contents of a
280 directory on the remote machine.
281 The listing includes any system-dependent information that the server
282 chooses to include; for example, most
283 .Ux
284 systems will produce
285 output from the command
286 .Ql ls \-l .
287 (See also
288 .Ic ls . )
289 If
290 .Ar remote-directory
291 is left unspecified, the current working directory is used.
292 If interactive prompting is on,
293 .Nm
294 will prompt the user to verify that the last argument is indeed the
295 target local file for receiving
296 .Ic dir
297 output.
298 If no local file is specified, or if
299 .Ar local-file
300 is
301 .Sq Fl ,
302 the output is sent to the terminal.
303 .Pp
304 As this command provides extra information which is system-dependent,
305 you should use the
306 .Ic nlist
307 command instead if you only want a plain list of files.
308 .It Ic disconnect
309 A synonym for
310 .Ic close .
311 .It Ic edit
312 Toggle command line editing, and context sensitive command and file
313 completion.
314 This is automatically enabled if input is from a terminal, and
315 disabled otherwise.
316 .It Ic epsv4
317 Toggle use of
318 .Dv EPSV/EPRT
319 commands on IPv4 FTP sessions.
320 Turning this option off may remedy problems with some
321 firewalls, e.g., IPFilter.
322 .It Ic exit
323 A synonym for
324 .Ic bye .
325 .It Ic ftp Ar host Op Ar port
326 A synonym for
327 .Ic open .
328 .It Ic form Ar format
329 Set the file transfer
330 .Ic form
331 to
332 .Ar format .
333 The default format is \*(Lqfile\*(Rq.
334 .It Ic get Ar remote-file Op Ar local-file
335 Retrieve the
336 .Ar remote-file
337 and store it on the local machine.
338 If the local
339 file name is not specified, it is given the same
340 name it has on the remote machine, subject to
341 alteration by the current
342 .Ic case  ,
343 .Ic ntrans
344 and
345 .Ic nmap
346 settings.
347 The current settings for
348 .Ic type  ,
349 .Ic form ,
350 .Ic mode
351 and
352 .Ic structure
353 are used while transferring the file.
354 .It Ic gate Op Ar host Op Ar port
355 Toggle gate-ftp mode.
356 This will not be permitted if the gate-ftp server hasn't been set
357 (either explicitly by the user, or from the
358 .Ev FTPSERVER
359 environment variable).
360 If
361 .Ar host
362 is given,
363 then gate-ftp mode will be enabled, and the gate-ftp server will be set to
364 .Ar host .
365 If
366 .Ar port
367 is also given, that will be used as the port to connect to on the
368 gate-ftp server.
369 .It Ic glob
370 Toggle filename expansion for
371 .Ic mdelete  ,
372 .Ic mget
373 and
374 .Ic mput .
375 If globbing is turned off with
376 .Ic glob  ,
377 the file name arguments
378 are taken literally and not expanded.
379 Globbing for
380 .Ic mput
381 is done as in
382 .Xr csh 1 .
383 For
384 .Ic mdelete
385 and
386 .Ic mget  ,
387 each remote file name is expanded
388 separately on the remote machine and the lists are not merged.
389 Expansion of a directory name is likely to be
390 different from expansion of the name of an ordinary file:
391 the exact result depends on the foreign operating system and ftp server,
392 and can be previewed by doing
393 .Ql mls remote-files \-
394 Note:
395 .Ic mget
396 and
397 .Ic mput
398 are not meant to transfer
399 entire directory subtrees of files.
400 That can be done by
401 transferring a
402 .Xr tar 1
403 archive of the subtree (in binary mode).
404 .It Ic hash Op Ar size
405 Toggle hash-sign (``#'') printing for each data block
406 transferred.
407 The size of a data block defaults to 1024 bytes.
408 This can be changed by specifying
409 .Ar size
410 in bytes.
411 .It Ic help Op Ar command
412 Print an informative message about the meaning of
413 .Ar command .
414 If no argument is given,
415 .Nm
416 prints a list of the known commands.
417 .It Ic idle Op Ar seconds
418 Set the inactivity timer on the remote server to
419 .Ar seconds
420 seconds.
421 If
422 .Ar seconds
423 is omitted, the current inactivity timer is printed.
424 .It Ic lcd Op Ar directory
425 Change the working directory on the local machine.
426 If
427 no
428 .Ar directory
429 is specified, the user's home directory is used.
430 .It Ic less Ar file
431 A synonym for
432 .Ic page .
433 .It Ic lpwd
434 Print the working directory on the local machine.
435 .It Ic \&ls Op Ar remote-directory Op Ar local-file
436 A synonym for
437 .Ic dir .
438 .It Ic macdef Ar macro-name
439 Define a macro.
440 Subsequent lines are stored as the macro
441 .Ar macro-name  ;
442 a null line (consecutive newline characters
443 in a file or
444 carriage returns from the terminal) terminates macro input mode.
445 There is a limit of 16 macros and 4096 total characters in all
446 defined macros.
447 Macros remain defined until a
448 .Ic close
449 command is executed.
450 The macro processor interprets `$' and `\e' as special characters.
451 A `$' followed by a number (or numbers) is replaced by the
452 corresponding argument on the macro invocation command line.
453 A `$' followed by an `i' signals that macro processor that the
454 executing macro is to be looped.
455 On the first pass `$i' is
456 replaced by the first argument on the macro invocation command line,
457 on the second pass it is replaced by the second argument, and so on.
458 A `\e' followed by any character is replaced by that character.
459 Use the `\e' to prevent special treatment of the `$'.
460 .It Ic mdelete Op Ar remote-files
461 Delete the
462 .Ar remote-files
463 on the remote machine.
464 .It Ic mdir Ar remote-files local-file
465 Like
466 .Ic dir  ,
467 except multiple remote files may be specified.
468 If interactive prompting is on,
469 .Nm
470 will prompt the user to verify that the last argument is indeed the
471 target local file for receiving
472 .Ic mdir
473 output.
474 .It Ic mget Ar remote-files
475 Expand the
476 .Ar remote-files
477 on the remote machine
478 and do a
479 .Ic get
480 for each file name thus produced.
481 See
482 .Ic glob
483 for details on the filename expansion.
484 Resulting file names will then be processed according to
485 .Ic case  ,
486 .Ic ntrans
487 and
488 .Ic nmap
489 settings.
490 Files are transferred into the local working directory,
491 which can be changed with
492 .Ql lcd directory ;
493 new local directories can be created with
494 .Ql "\&! mkdir directory" .
495 .It Ic mkdir Ar directory-name
496 Make a directory on the remote machine.
497 .It Ic mls Ar remote-files local-file
498 Like
499 .Ic ls  ,
500 except multiple remote files may be specified,
501 and the
502 .Ar local-file
503 must be specified.
504 If interactive prompting is on,
505 .Nm
506 will prompt the user to verify that the last argument is indeed the
507 target local file for receiving
508 .Ic mls
509 output.
510 .It Ic mode Op Ar mode-name
511 Set the file transfer
512 .Ic mode
513 to
514 .Ar mode-name .
515 The default mode is \*(Lqstream\*(Rq mode.
516 .It Ic modtime Ar file-name
517 Show the last modification time of the file on the remote machine.
518 .It Ic more Ar file
519 A synonym for
520 .Ic page .
521 .It Ic mput Ar local-files
522 Expand wild cards in the list of local files given as arguments
523 and do a
524 .Ic put
525 for each file in the resulting list.
526 See
527 .Ic glob
528 for details of filename expansion.
529 Resulting file names will then be processed according to
530 .Ic ntrans
531 and
532 .Ic nmap
533 settings.
534 .It Ic msend Ar local-files
535 A synonym for
536 .Ic mput .
537 .It Ic newer Ar file-name
538 Get the file only if the modification time of the remote file is more
539 recent that the file on the current system.
540 If the file does not
541 exist on the current system, the remote file is considered
542 .Ic newer .
543 Otherwise, this command is identical to
544 .Ar get .
545 .It Ic nlist Op Ar remote-directory Op Ar local-file
546 Print a list of the files in a
547 directory on the remote machine.
548 If
549 .Ar remote-directory
550 is left unspecified, the current working directory is used.
551 If interactive prompting is on,
552 .Nm
553 will prompt the user to verify that the last argument is indeed the
554 target local file for receiving
555 .Ic ls
556 output.
557 If no local file is specified, or if
558 .Ar local-file
559 is
560 .Fl  ,
561 the output is sent to the terminal.
562 .Pp
563 Note that this command only returns the filenames in the remote
564 directory.  If you wish to see more information about the files (often
565 size, modification time, and so on),
566 you should use the
567 .Ic dir
568 command instead.
569 .It Ic nmap Op Ar inpattern outpattern
570 Set or unset the filename mapping mechanism.
571 If no arguments are specified, the filename mapping mechanism is unset.
572 If arguments are specified, remote filenames are mapped during
573 .Ic mput
574 commands and
575 .Ic put
576 commands issued without a specified remote target filename.
577 If arguments are specified, local filenames are mapped during
578 .Ic mget
579 commands and
580 .Ic get
581 commands issued without a specified local target filename.
582 This command is useful when connecting to a
583 .No non\- Ns Ux
584 remote computer
585 with different file naming conventions or practices.
586 The mapping follows the pattern set by
587 .Ar inpattern
588 and
589 .Ar outpattern .
590 .Op Ar Inpattern
591 is a template for incoming filenames (which may have already been
592 processed according to the
593 .Ic ntrans
594 and
595 .Ic case
596 settings).
597 Variable templating is accomplished by including the
598 sequences `$1', `$2', ..., `$9' in
599 .Ar inpattern .
600 Use `\\' to prevent this special treatment of the `$' character.
601 All other characters are treated literally, and are used to determine the
602 .Ic nmap
603 .Op Ar inpattern
604 variable values.
605 For example, given
606 .Ar inpattern
607 $1.$2 and the remote file name "mydata.data", $1 would have the value
608 "mydata", and $2 would have the value "data".
609 The
610 .Ar outpattern
611 determines the resulting mapped filename.
612 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
613 from the
614 .Ar inpattern
615 template.
616 The sequence `$0' is replace by the original filename.
617 Additionally, the sequence
618 .Sq Op Ar seq1 , Ar seq2
619 is replaced by
620 .Op Ar seq1
621 if
622 .Ar seq1
623 is not a null string; otherwise it is replaced by
624 .Ar seq2 .
625 For example, the command
626 .Pp
627 .Bd -literal -offset indent -compact
628 nmap $1.$2.$3 [$1,$2].[$2,file]
629 .Ed
630 .Pp
631 would yield
632 the output filename "myfile.data" for input filenames "myfile.data" and
633 "myfile.data.old", "myfile.file" for the input filename "myfile", and
634 "myfile.myfile" for the input filename ".myfile".
635 Spaces may be included in
636 .Ar outpattern  ,
637 as in the example: `nmap $1 sed "s/  *$//" > $1' .
638 Use the `\e' character to prevent special treatment
639 of the `$','[',']' and `,' characters.
640 .It Ic ntrans Op Ar inchars Op Ar outchars
641 Set or unset the filename character translation mechanism.
642 If no arguments are specified, the filename character
643 translation mechanism is unset.
644 If arguments are specified, characters in
645 remote filenames are translated during
646 .Ic mput
647 commands and
648 .Ic put
649 commands issued without a specified remote target filename.
650 If arguments are specified, characters in
651 local filenames are translated during
652 .Ic mget
653 commands and
654 .Ic get
655 commands issued without a specified local target filename.
656 This command is useful when connecting to a
657 .No non\- Ns Ux
658 remote computer
659 with different file naming conventions or practices.
660 Characters in a filename matching a character in
661 .Ar inchars
662 are replaced with the corresponding character in
663 .Ar outchars .
664 If the character's position in
665 .Ar inchars
666 is longer than the length of
667 .Ar outchars  ,
668 the character is deleted from the file name.
669 .It Ic open Ar host Op Ar port
670 Establish a connection to the specified
671 .Ar host
672 .Tn FTP
673 server.
674 An optional port number may be supplied,
675 in which case,
676 .Nm
677 will attempt to contact an
678 .Tn FTP
679 server at that port.
680 If the
681 .Ic auto-login
682 option is on (default),
683 .Nm
684 will also attempt to automatically log the user in to
685 the
686 .Tn FTP
687 server (see below).
688 .It Ic page Ar file
689 Retrieve
690 .Ic file
691 and display with the program defined in
692 .Ev PAGER
693 (which defaults to
694 .Xr more 1 ) .
695 .It Ic passive
696 Toggle passive mode.  If passive mode is turned on
697 (default is off), the ftp client will
698 send a
699 .Dv PASV
700 command for all data connections instead of the usual
701 .Dv PORT
702 command.  The
703 .Dv PASV
704 command requests that the remote server open a port for the data connection
705 and return the address of that port.  The remote server listens on that
706 port and the client connects to it.  When using the more traditional
707 .Dv PORT
708 command, the client listens on a port and sends that address to the remote
709 server, who connects back to it.  Passive mode is useful when using
710 .Nm
711 through a gateway router or host that controls the directionality of
712 traffic.
713 (Note that though ftp servers are required to support the
714 .Dv PASV
715 command by RFC 1123, some do not.
716 Please note that if you are connecting to IPv6 ftp server,
717 the program will use
718 .Dv EPSV/EPRT
719 pair and
720 .Dv LPSV/LPRT
721 pair,
722 instead of
723 .Dv PASV
724 and
725 .Dv PORT .
726 The meaning is the same.)
727 .It Ic preserve
728 Toggle preservation of modification times on retrieved files.
729 .It Ic progress
730 Toggle display of transfer progress bar.
731 The progress bar will be disabled for a transfer that has
732 .Ar local-file
733 as
734 .Sq Fl
735 or a command that starts with
736 .Sq \&| .
737 Refer to
738 .Sx FILE NAMING CONVENTIONS
739 for more information.
740 .It Ic prompt
741 Toggle interactive prompting.
742 Interactive prompting
743 occurs during multiple file transfers to allow the
744 user to selectively retrieve or store files.
745 If prompting is turned off (default is on), any
746 .Ic mget
747 or
748 .Ic mput
749 will transfer all files, and any
750 .Ic mdelete
751 will delete all files.
752 .Pp
753 When prompting is on, the following commands are available at a prompt:
754 .Bl -tag -width 2n -offset indent
755 .It Ic n
756 Do not transfer the file.
757 .It Ic a
758 Answer
759 .Sq yes
760 to the current file, and automatically answer
761 .Sq yes
762 to any remaining files for the current command.
763 .It Ic p
764 Answer
765 .Sq yes
766 to the current file, and turn off prompt mode
767 (as if
768 .Dq prompt off
769 had been given).
770 .El
771 .Pp
772 Any other reponse will answer
773 .Sq yes
774 to the current file.
775 .It Ic proxy Ar ftp-command
776 Execute an ftp command on a secondary control connection.
777 This command allows simultaneous connection to two remote ftp
778 servers for transferring files between the two servers.
779 The first
780 .Ic proxy
781 command should be an
782 .Ic open  ,
783 to establish the secondary control connection.
784 Enter the command "proxy ?" to see other ftp commands executable on the
785 secondary connection.
786 The following commands behave differently when prefaced by
787 .Ic proxy  :
788 .Ic open
789 will not define new macros during the auto-login process,
790 .Ic close
791 will not erase existing macro definitions,
792 .Ic get
793 and
794 .Ic mget
795 transfer files from the host on the primary control connection
796 to the host on the secondary control connection, and
797 .Ic put  ,
798 .Ic mput
799 and
800 .Ic append
801 transfer files from the host on the secondary control connection
802 to the host on the primary control connection.
803 Third party file transfers depend upon support of the ftp protocol
804 .Dv PASV
805 command by the server on the secondary control connection.
806 .It Ic put Ar local-file Op Ar remote-file
807 Store a local file on the remote machine.
808 If
809 .Ar remote-file
810 is left unspecified, the local file name is used
811 after processing according to any
812 .Ic ntrans
813 or
814 .Ic nmap
815 settings
816 in naming the remote file.
817 File transfer uses the
818 current settings for
819 .Ic type  ,
820 .Ic format ,
821 .Ic mode
822 and
823 .Ic structure .
824 .It Ic pwd
825 Print the name of the current working directory on the remote
826 machine.
827 .It Ic quit
828 A synonym for
829 .Ic bye .
830 .It Ic quote Ar arg1 arg2 ...
831 The arguments specified are sent, verbatim, to the remote
832 .Tn FTP
833 server.
834 .It Ic recv Ar remote-file Op Ar local-file
835 A synonym for
836 .Ic get .
837 .It Ic reget Ar remote-file Op Ar local-file
838 Reget acts like get, except that if
839 .Ar local-file
840 exists and is
841 smaller than
842 .Ar remote-file  ,
843 .Ar local-file
844 is presumed to be
845 a partially transferred copy of
846 .Ar remote-file
847 and the transfer
848 is continued from the apparent point of failure.
849 This command
850 is useful when transferring very large files over networks that
851 are prone to dropping connections.
852 .It Ic remotehelp Op Ar command-name
853 Request help from the remote
854 .Tn FTP
855 server.
856 If a
857 .Ar command-name
858 is specified it is supplied to the server as well.
859 .It Ic rstatus Op Ar file-name
860 With no arguments, show status of remote machine.
861 If
862 .Ar file-name
863 is specified, show status of
864 .Ar file-name
865 on remote machine.
866 .It Ic rename Op Ar from Op Ar to
867 Rename the file
868 .Ar from
869 on the remote machine, to the file
870 .Ar to .
871 .It Ic reset
872 Clear reply queue.
873 This command re-synchronizes command/reply sequencing with the remote
874 ftp server.
875 Resynchronization may be necessary following a violation of the ftp protocol
876 by the remote server.
877 .It Ic restart Ar marker
878 Restart the immediately following
879 .Ic get
880 or
881 .Ic put
882 at the
883 indicated
884 .Ar marker .
885 On
886 .Ux
887 systems, marker is usually a byte
888 offset into the file.
889 .It Ic restrict
890 Toggle data port range restrictions.
891 When not operating in passive mode,  the
892 .Nm
893 client program requests that the remote server open a connection back
894 to the client host on a separate data port.  In previous versions, that
895 remote port fell in the range 1024..4999.  However, most firewall setups
896 filter that range of TCP ports because other services reside there.
897 The default behavior now is for the client to request that the server
898 connect back to the client using the port range 49152..65535.  Firewall
899 administrators can chose to allow TCP connections in that range, if they
900 deem it to not be a security risk.
901 .It Ic rmdir Ar directory-name
902 Delete a directory on the remote machine.
903 .It Ic runique
904 Toggle storing of files on the local system with unique filenames.
905 If a file already exists with a name equal to the target
906 local filename for a
907 .Ic get
908 or
909 .Ic mget
910 command, a ".1" is appended to the name.
911 If the resulting name matches another existing file,
912 a ".2" is appended to the original name.
913 If this process continues up to ".99", an error
914 message is printed, and the transfer does not take place.
915 The generated unique filename will be reported.
916 Note that
917 .Ic runique
918 will not affect local files generated from a shell command
919 (see below).
920 The default value is off.
921 .It Ic send Ar local-file Op Ar remote-file
922 A synonym for
923 .Ic put .
924 .It Ic sendport
925 Toggle the use of
926 .Dv PORT
927 commands.
928 By default,
929 .Nm
930 will attempt to use a
931 .Dv PORT
932 command when establishing
933 a connection for each data transfer.
934 The use of
935 .Dv PORT
936 commands can prevent delays
937 when performing multiple file transfers.
938 If the
939 .Dv PORT
940 command fails,
941 .Nm
942 will use the default data port.
943 When the use of
944 .Dv PORT
945 commands is disabled, no attempt will be made to use
946 .Dv PORT
947 commands for each data transfer.
948 This is useful
949 for certain
950 .Tn FTP
951 implementations which do ignore
952 .Dv PORT
953 commands but, incorrectly, indicate they've been accepted.
954 .It Ic site Ar arg1 arg2 ...
955 The arguments specified are sent, verbatim, to the remote
956 .Tn FTP
957 server as a
958 .Dv SITE
959 command.
960 .It Ic size Ar file-name
961 Return size of
962 .Ar file-name
963 on remote machine.
964 .It Ic status
965 Show the current status of
966 .Nm .
967 .It Ic struct Op Ar struct-name
968 Set the file transfer
969 .Ar structure
970 to
971 .Ar struct-name .
972 By default \*(Lqstream\*(Rq structure is used.
973 .It Ic sunique
974 Toggle storing of files on remote machine under unique file names.
975 Remote ftp server must support ftp protocol
976 .Dv STOU
977 command for
978 successful completion.
979 The remote server will report unique name.
980 Default value is off.
981 .It Ic system
982 Show the type of operating system running on the remote machine.
983 .It Ic tenex
984 Set the file transfer type to that needed to
985 talk to
986 .Tn TENEX
987 machines.
988 .It Ic trace
989 Toggle packet tracing.
990 .It Ic type Op Ar type-name
991 Set the file transfer
992 .Ic type
993 to
994 .Ar type-name .
995 If no type is specified, the current type
996 is printed.
997 The default type is network
998 .Tn ASCII .
999 .It Ic umask Op Ar newmask
1000 Set the default umask on the remote server to
1001 .Ar newmask .
1002 If
1003 .Ar newmask
1004 is omitted, the current umask is printed.
1005 .It Xo
1006 .Ic user Ar user-name
1007 .Op Ar password Op Ar account
1008 .Xc
1009 Identify yourself to the remote
1010 .Tn FTP
1011 server.
1012 If the
1013 .Ar password
1014 is not specified and the server requires it,
1015 .Nm
1016 will prompt the user for it (after disabling local echo).
1017 If an
1018 .Ar account
1019 field is not specified, and the
1020 .Tn FTP
1021 server
1022 requires it, the user will be prompted for it.
1023 If an
1024 .Ar account
1025 field is specified, an account command will
1026 be relayed to the remote server after the login sequence
1027 is completed if the remote server did not require it
1028 for logging in.
1029 Unless
1030 .Nm
1031 is invoked with \*(Lqauto-login\*(Rq disabled, this
1032 process is done automatically on initial connection to
1033 the
1034 .Tn FTP
1035 server.
1036 .It Ic verbose
1037 Toggle verbose mode.
1038 In verbose mode, all responses from
1039 the
1040 .Tn FTP
1041 server are displayed to the user.
1042 In addition,
1043 if verbose is on, when a file transfer completes, statistics
1044 regarding the efficiency of the transfer are reported.
1045 By default,
1046 verbose is on.
1047 .It Ic \&? Op Ar command
1048 A synonym for
1049 .Ic help .
1050 .El
1051 .Pp
1052 Command arguments which have embedded spaces may be quoted with
1053 quote `"' marks.
1054 .Pp
1055 Commands which toggle settings can take an explicit
1056 .Ic on
1057 or
1058 .Ic off
1059 argument to force the setting appropriately.
1060 .Pp
1061 If
1062 .Nm
1063 receives a
1064 .Dv SIGINFO
1065 (see the
1066 .Dq status
1067 argument of
1068 .Xr stty 1 )
1069 signal whilst a transfer is in progress, the current transfer rate
1070 statistics will be written to the standard error output, in the
1071 same format as the standard completion message.
1072 .Sh AUTO-FETCHING FILES
1073 In addition to standard commands, this version of
1074 .Nm
1075 supports an auto-fetch feature.
1076 To enable auto-fetch, simply pass the list of hostnames/files
1077 on the command line.
1078 .Pp
1079 The following formats are valid syntax for an auto-fetch element:
1080 .Bl -tag -width "host:/file"
1081 .It host:/file
1082 .Dq Classic
1083 ftp format
1084 .It ftp://[user:password@]host[:port]/file
1085 An ftp URL, retrieved using the ftp protocol if
1086 .Ev ftp_proxy
1087 isn't defined.
1088 Otherwise, transfer using http via the proxy defined in
1089 .Ev ftp_proxy .
1090 If
1091 .Ar user:password@
1092 is given and
1093 .Ev ftp_proxy
1094 isn't defined, login as
1095 .Ar user
1096 with a password of
1097 .Ar password .
1098 .It http://host[:port]/file
1099 An HTTP URL, retrieved using the http protocol.
1100 If
1101 .Ev http_proxy
1102 is defined, it is used as a URL to an HTTP proxy server.
1103 .El
1104 .Pp
1105 If a classic format or a ftp URL format has a trailing
1106 .Sq / ,
1107 then
1108 .Nm
1109 will connect to the site and
1110 .Ic cd
1111 to the directory given as the path, and leave the user in interactive
1112 mode ready for further input.
1113 .Pp
1114 If successive auto-fetch ftp elements refer to the same host, then
1115 the connection is maintained between transfers, reducing overhead on
1116 connection creation and deletion.
1117 .Pp
1118 If
1119 .Ic file
1120 contains a glob character and globbing is enabled,
1121 (see
1122 .Ic glob ) ,
1123 then the equivalent of
1124 .Ic "mget file"
1125 is performed.
1126 .Pp
1127 If the directory component of
1128 .Ic file
1129 contains no globbing characters,
1130 it is stored in the current directory as the
1131 .Xr basename 1
1132 of
1133 .Ic file .
1134 Otherwise, the remote name is used as the local name.
1135 .Sh ABORTING A FILE TRANSFER
1136 To abort a file transfer, use the terminal interrupt key
1137 (usually Ctrl-C).
1138 Sending transfers will be immediately halted.
1139 Receiving transfers will be halted by sending a ftp protocol
1140 .Dv ABOR
1141 command to the remote server, and discarding any further data received.
1142 The speed at which this is accomplished depends upon the remote
1143 server's support for
1144 .Dv ABOR
1145 processing.
1146 If the remote server does not support the
1147 .Dv ABOR
1148 command, an
1149 .Ql ftp>
1150 prompt will not appear until the remote server has completed
1151 sending the requested file.
1152 .Pp
1153 The terminal interrupt key sequence will be ignored when
1154 .Nm
1155 has completed any local processing and is awaiting a reply
1156 from the remote server.
1157 A long delay in this mode may result from the ABOR processing described
1158 above, or from unexpected behavior by the remote server, including
1159 violations of the ftp protocol.
1160 If the delay results from unexpected remote server behavior, the local
1161 .Nm
1162 program must be killed by hand.
1163 .Sh FILE NAMING CONVENTIONS
1164 Files specified as arguments to
1165 .Nm
1166 commands are processed according to the following rules.
1167 .Bl -enum
1168 .It
1169 If the file name
1170 .Sq Fl
1171 is specified, the
1172 .Ar stdin
1173 (for reading) or
1174 .Ar stdout
1175 (for writing) is used.
1176 .It
1177 If the first character of the file name is
1178 .Sq \&| ,
1179 the
1180 remainder of the argument is interpreted as a shell command.
1181 .Nm
1182 then forks a shell, using
1183 .Xr popen 3
1184 with the argument supplied, and reads (writes) from the stdin
1185 (stdout).
1186 If the shell command includes spaces, the argument
1187 must be quoted; e.g.\&
1188 \*(Lq" ls -lt"\*(Rq.
1189 A particularly
1190 useful example of this mechanism is: \*(Lqdir \&|more\*(Rq.
1191 .It
1192 Failing the above checks, if
1193 .Dq globbing
1194 is enabled,
1195 local file names are expanded
1196 according to the rules used in the
1197 .Xr csh 1 ;
1198 c.f. the
1199 .Ic glob
1200 command.
1201 If the
1202 .Nm
1203 command expects a single local file (e.g.\&
1204 .Ic put  ) ,
1205 only the first filename generated by the "globbing" operation is used.
1206 .It
1207 For
1208 .Ic mget
1209 commands and
1210 .Ic get
1211 commands with unspecified local file names, the local filename is
1212 the remote filename, which may be altered by a
1213 .Ic case  ,
1214 .Ic ntrans ,
1215 or
1216 .Ic nmap
1217 setting.
1218 The resulting filename may then be altered if
1219 .Ic runique
1220 is on.
1221 .It
1222 For
1223 .Ic mput
1224 commands and
1225 .Ic put
1226 commands with unspecified remote file names, the remote filename is
1227 the local filename, which may be altered by a
1228 .Ic ntrans
1229 or
1230 .Ic nmap
1231 setting.
1232 The resulting filename may then be altered by the remote server if
1233 .Ic sunique
1234 is on.
1235 .El
1236 .Sh FILE TRANSFER PARAMETERS
1237 The FTP specification specifies many parameters which may
1238 affect a file transfer.
1239 The
1240 .Ic type
1241 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1242 \*(Lqebcdic\*(Rq and \*(Lqlocal byte size\*(Rq (for
1243 .Tn PDP Ns -10's
1244 and
1245 .Tn PDP Ns -20's
1246 mostly).
1247 .Nm
1248 supports the ascii and image types of file transfer,
1249 plus local byte size 8 for
1250 .Ic tenex
1251 mode transfers.
1252 .Pp
1253 .Nm
1254 supports only the default values for the remaining
1255 file transfer parameters:
1256 .Ic mode  ,
1257 .Ic form
1258 and
1259 .Ic struct .
1260 .Sh THE .netrc FILE
1261 The
1262 .Pa .netrc
1263 file contains login and initialization information
1264 used by the auto-login process.
1265 It resides in the user's home directory.
1266 The following tokens are recognized; they may be separated by spaces,
1267 tabs, or new-lines:
1268 .Bl -tag -width password
1269 .It Ic machine Ar name
1270 Identify a remote machine
1271 .Ar name .
1272 The auto-login process searches the
1273 .Pa .netrc
1274 file for a
1275 .Ic machine
1276 token that matches the remote machine specified on the
1277 .Nm
1278 command line or as an
1279 .Ic open
1280 command argument.
1281 Once a match is made, the subsequent
1282 .Pa .netrc
1283 tokens are processed,
1284 stopping when the end of file is reached or another
1285 .Ic machine
1286 or a
1287 .Ic default
1288 token is encountered.
1289 .It Ic default
1290 This is the same as
1291 .Ic machine
1292 .Ar name
1293 except that
1294 .Ic default
1295 matches any name.
1296 There can be only one
1297 .Ic default
1298 token, and it must be after all
1299 .Ic machine
1300 tokens.
1301 This is normally used as:
1302 .Pp
1303 .Dl default login anonymous password user@site
1304 .Pp
1305 thereby giving the user
1306 .Ar automatic
1307 anonymous ftp login to
1308 machines not specified in
1309 .Pa .netrc .
1310 This can be overridden
1311 by using the
1312 .Fl n
1313 flag to disable auto-login.
1314 .It Ic login Ar name
1315 Identify a user on the remote machine.
1316 If this token is present, the auto-login process will initiate
1317 a login using the specified
1318 .Ar name .
1319 .It Ic password Ar string
1320 Supply a password.
1321 If this token is present, the auto-login process will supply the
1322 specified string if the remote server requires a password as part
1323 of the login process.
1324 Note that if this token is present in the
1325 .Pa .netrc
1326 file for any user other
1327 than
1328 .Ar anonymous  ,
1329 .Nm
1330 will abort the auto-login process if the
1331 .Pa .netrc
1332 is readable by
1333 anyone besides the user.
1334 .It Ic account Ar string
1335 Supply an additional account password.
1336 If this token is present, the auto-login process will supply the
1337 specified string if the remote server requires an additional
1338 account password, or the auto-login process will initiate an
1339 .Dv ACCT
1340 command if it does not.
1341 .It Ic macdef Ar name
1342 Define a macro.
1343 This token functions like the
1344 .Nm
1345 .Ic macdef
1346 command functions.
1347 A macro is defined with the specified name; its contents begin with the
1348 next
1349 .Pa .netrc
1350 line and continue until a null line (consecutive new-line
1351 characters) is encountered.
1352 If a macro named
1353 .Ic init
1354 is defined, it is automatically executed as the last step in the
1355 auto-login process.
1356 .El
1357 .Sh COMMAND LINE EDITING
1358 .Nm
1359 supports interactive command line editing, via the
1360 .Xr editline 3
1361 library.
1362 It is enabled with the
1363 .Ic edit
1364 command, and is enabled by default if input is from a tty.
1365 Previous lines can be recalled and edited with the arrow keys,
1366 and other GNU Emacs-style editing keys may be used as well.
1367 .Pp
1368 The
1369 .Xr editline 3
1370 library is configured with a
1371 .Pa .editrc
1372 file - refer to
1373 .Xr editrc 5
1374 for more information.
1375 .Pp
1376 An extra key binding is available to
1377 .Nm
1378 to provide context sensitive command and filename completion
1379 (including remote file completion).
1380 To use this, bind a key to the
1381 .Xr editline 3
1382 command
1383 .Ic ftp-complete .
1384 By default, this is bound to the TAB key.
1385 .Sh ENVIRONMENT
1386 .Nm
1387 utilizes the following environment variables.
1388 .Bl -tag -width "FTP_PASSIVE_MODE"
1389 .It Ev FTP_PASSIVE_MODE
1390 If this variable is set to something else than
1391 .Sq NO ,
1392 .Nm
1393 will use passive mode by default.
1394 .It Ev FTPSERVER
1395 Host to use as gate-ftp server when
1396 .Ic gate
1397 is enabled.
1398 .It Ev FTPSERVERPORT
1399 Port to use when connecting to gate-ftp server when
1400 .Ic gate
1401 is enabled.
1402 Default is port returned by a
1403 .Fn getservbyname
1404 lookup of
1405 .Dq ftpgate/tcp .
1406 .It Ev HOME
1407 For default location of a
1408 .Pa .netrc
1409 file, if one exists.
1410 .It Ev PAGER
1411 Used by
1412 .Ic page
1413 to display files.
1414 .It Ev SHELL
1415 For default shell.
1416 .It Ev ftp_proxy
1417 URL of FTP proxy to use when making FTP URL requests
1418 (if not defined, use the standard ftp protocol).
1419 .It Ev http_proxy
1420 URL of HTTP proxy to use when making HTTP URL requests.
1421 .El
1422 .Sh SEE ALSO
1423 .Xr getservbyname 3 ,
1424 .Xr editrc 5 ,
1425 .Xr services 5 ,
1426 .Xr ftpd 8
1427 .Sh NOTES
1428 The
1429 .Xr pftp 1
1430 and
1431 .Xr gate-ftp 1
1432 commands are links to
1433 .Nm .
1434 .Sh HISTORY
1435 The
1436 .Nm
1437 command appeared in
1438 .Bx 4.2 .
1439 .Pp
1440 Various features such as command line editing, context sensitive
1441 command and file completion, dynamic progress bar, automatic
1442 fetching of files, ftp and http URLs, and modification time
1443 preservation were implemented in
1444 .Nx 1.3
1445 by Luke Mewburn, with assistance from Jason Thorpe.
1446 .Pp
1447 IPv6 support was added by WIDE/KAME Project.
1448 .Sh BUGS
1449 Correct execution of many commands depends upon proper behavior
1450 by the remote server.
1451 .Pp
1452 An error in the treatment of carriage returns
1453 in the
1454 .Bx 4.2
1455 ascii-mode transfer code
1456 has been corrected.
1457 This correction may result in incorrect transfers of binary files
1458 to and from
1459 .Bx 4.2
1460 servers using the ascii type.
1461 Avoid this problem by using the binary image type.
1462 .Pp
1463 Proxying functionalities, such as
1464 .Ev ftp_proxy ,
1465 may not work for IPv6 connection.