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