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