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