1 .\" $NetBSD: ftp.1,v 1.11 1995/09/08 01:06:24 tls Exp $
3 .\" Copyright (c) 1985, 1989, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
54 .Op Fl -no-gss-bindings
58 is the user interface to the
60 standard File Transfer Protocol.
61 The program allows a user to transfer files to and from a
64 Modifications has been made so that it almost follows the ftpsec
67 Options may be specified at the command line, or to the
71 Enables packet tracing.
75 to show all responses from the remote server, as well
76 as report on data transfer statistics.
80 from attempting \*(Lqauto-login\*(Rq upon initial connection.
81 If auto-login is enabled,
85 (see below) file in the user's home directory for an entry describing
86 an account on the remote machine.
89 will prompt for the remote machine login name (default is the user
90 identity on the local machine), and, if necessary, prompt for a password
91 and an account with which to login.
93 Turns off interactive prompting during
94 multiple file transfers.
100 Disables file name globbing.
101 .It Fl -no-gss-bindings
102 use GSS-API bindings when talking to peer (ie make sure IP addresses match).
104 Disables command line editing.
107 The client host with which
109 is to communicate may be specified on the command line.
112 will immediately attempt to establish a connection to an
114 server on that host; otherwise,
116 will enter its command interpreter and await instructions
120 is awaiting commands from the user the prompt
122 is provided to the user.
123 The following commands are recognized
127 .It Ic \&! Op Ar command Op Ar args
128 Invoke an interactive shell on the local machine.
129 If there are arguments, the first is taken to be a command to execute
130 directly, with the rest of the arguments as its arguments.
131 .It Ic \&$ Ar macro-name Op Ar args
134 that was defined with the
137 Arguments are passed to the macro unglobbed.
138 .It Ic account Op Ar passwd
139 Supply a supplemental password required by a remote system for access
140 to resources once a login has been successfully completed.
141 If no argument is included, the user will be prompted for an account
142 password in a non-echoing input mode.
143 .It Ic append Ar local-file Op Ar remote-file
144 Append a local file to a file on the remote machine.
147 is left unspecified, the local file name is used in naming the
148 remote file after being altered by any
153 File transfer uses the current settings for
160 Set the file transfer
164 This is the default type.
166 Arrange that a bell be sounded after each file transfer
167 command is completed.
169 Set the file transfer
171 to support binary image transfer.
175 session with the remote server
178 An end of file will also terminate the session and exit.
180 Toggle remote computer file name case mapping during
185 is on (default is off), remote computer file names with all letters in
186 upper case are written in the local directory with the letters mapped
188 .It Ic \&cd Ar remote-directory
189 Change the working directory on the remote machine
191 .Ar remote-directory .
193 Change the remote machine working directory to the parent of the
194 current remote machine working directory.
195 .It Ic chmod Ar mode file-name
196 Change the permission modes of the file
204 session with the remote server, and
205 return to the command interpreter.
206 Any defined macros are erased.
208 Toggle carriage return stripping during
209 ascii type file retrieval.
210 Records are denoted by a carriage return/linefeed sequence
211 during ascii type file transfer.
214 is on (the default), carriage returns are stripped from this
215 sequence to conform with the
217 single linefeed record
221 remote systems may contain single linefeeds;
222 when an ascii type transfer is made, these linefeeds may be
223 distinguished from a record delimiter only when
226 .It Ic delete Ar remote-file
229 on the remote machine.
230 .It Ic debug Op Ar debug-value
231 Toggle debugging mode.
234 is specified it is used to set the debugging level.
235 When debugging is on,
237 prints each command sent to the remote machine, preceded
242 .Op Ar remote-directory
245 Print a listing of the directory contents in the
247 .Ar remote-directory ,
248 and, optionally, placing the output in
250 If interactive prompting is on,
252 will prompt the user to verify that the last argument is indeed the
253 target local file for receiving
256 If no directory is specified, the current working
257 directory on the remote machine is used.
259 file is specified, or
263 output comes to the terminal.
267 .It Ic form Ar format
268 Set the file transfer
272 The default format is \*(Lqfile\*(Rq.
273 .It Ic get Ar remote-file Op Ar local-file
276 and store it on the local machine.
278 file name is not specified, it is given the same
279 name it has on the remote machine, subject to
280 alteration by the current
286 The current settings for
292 are used while transferring the file.
294 Toggle filename expansion for
299 If globbing is turned off with
301 the file name arguments
302 are taken literally and not expanded.
311 each remote file name is expanded
312 separately on the remote machine and the lists are not merged.
313 Expansion of a directory name is likely to be
314 different from expansion of the name of an ordinary file:
315 the exact result depends on the foreign operating system and ftp server,
316 and can be previewed by doing
317 .Ql mls remote-files \- .
318 As a security measure, remotely globbed files that starts with
322 will not be automatically received. If you have interactive prompting
323 turned off, these filenames will be ignored. Note:
327 are not meant to transfer
328 entire directory subtrees of files.
332 archive of the subtree (in binary mode).
334 Toggle hash-sign (``#'') printing for each data block
336 The size of a data block is 1024 bytes.
337 .It Ic help Op Ar command
338 Print an informative message about the meaning of
340 If no argument is given,
342 prints a list of the known commands.
343 .It Ic idle Op Ar seconds
344 Set the inactivity timer on the remote server to
349 is omitted, the current inactivity timer is printed.
350 .It Ic lcd Op Ar directory
351 Change the working directory on the local machine.
355 is specified, the user's home directory is used.
358 .Op Ar remote-directory
361 Print a listing of the contents of a
362 directory on the remote machine.
363 The listing includes any system-dependent information that the server
364 chooses to include; for example, most
367 output from the command
373 is left unspecified, the current working directory is used.
374 If interactive prompting is on,
376 will prompt the user to verify that the last argument is indeed the
377 target local file for receiving
380 If no local file is specified, or if
384 the output is sent to the terminal.
385 .It Ic macdef Ar macro-name
387 Subsequent lines are stored as the macro
389 a null line (consecutive newline characters
391 carriage returns from the terminal) terminates macro input mode.
392 There is a limit of 16 macros and 4096 total characters in all
394 Macros remain defined until a
397 The macro processor interprets `$' and `\e' as special characters.
398 A `$' followed by a number (or numbers) is replaced by the
399 corresponding argument on the macro invocation command line.
400 A `$' followed by an `i' signals that macro processor that the
401 executing macro is to be looped.
402 On the first pass `$i' is
403 replaced by the first argument on the macro invocation command line,
404 on the second pass it is replaced by the second argument, and so on.
405 A `\e' followed by any character is replaced by that character.
406 Use the `\e' to prevent special treatment of the `$'.
407 .It Ic mdelete Op Ar remote-files
410 on the remote machine.
411 .It Ic mdir Ar remote-files local-file
414 except multiple remote files may be specified.
415 If interactive prompting is on,
417 will prompt the user to verify that the last argument is indeed the
418 target local file for receiving
421 .It Ic mget Ar remote-files
424 on the remote machine
427 for each file name thus produced.
430 for details on the filename expansion.
431 Resulting file names will then be processed according to
437 Files are transferred into the local working directory,
438 which can be changed with
440 new local directories can be created with
441 .Ql "\&! mkdir directory" .
442 .It Ic mkdir Ar directory-name
443 Make a directory on the remote machine.
444 .It Ic mls Ar remote-files local-file
447 except multiple remote files may be specified,
451 If interactive prompting is on,
453 will prompt the user to verify that the last argument is indeed the
454 target local file for receiving
457 .It Ic mode Op Ar mode-name
458 Set the file transfer
462 The default mode is \*(Lqstream\*(Rq mode.
463 .It Ic modtime Ar file-name
464 Show the last modification time of the file on the remote machine.
465 .It Ic mput Ar local-files
466 Expand wild cards in the list of local files given as arguments
469 for each file in the resulting list.
472 for details of filename expansion.
473 Resulting file names will then be processed according to
478 .It Ic newer Ar file-name
479 Get the file only if the modification time of the remote file is more
480 recent that the file on the current system.
482 exist on the current system, the remote file is considered
484 Otherwise, this command is identical to
488 .Op Ar remote-directory
491 Print a list of the files in a
492 directory on the remote machine.
495 is left unspecified, the current working directory is used.
496 If interactive prompting is on,
498 will prompt the user to verify that the last argument is indeed the
499 target local file for receiving
502 If no local file is specified, or if
506 the output is sent to the terminal.
507 .It Ic nmap Op Ar inpattern outpattern
508 Set or unset the filename mapping mechanism.
509 If no arguments are specified, the filename mapping mechanism is unset.
510 If arguments are specified, remote filenames are mapped during
514 commands issued without a specified remote target filename.
515 If arguments are specified, local filenames are mapped during
519 commands issued without a specified local target filename.
520 This command is useful when connecting to a
523 with different file naming conventions or practices.
524 The mapping follows the pattern set by
529 is a template for incoming filenames (which may have already been
530 processed according to the
535 Variable templating is accomplished by including the
536 sequences `$1', `$2', ..., `$9' in
538 Use `\\' to prevent this special treatment of the `$' character.
539 All other characters are treated literally, and are used to determine the
545 $1.$2 and the remote file name "mydata.data", $1 would have the value
546 "mydata", and $2 would have the value "data".
549 determines the resulting mapped filename.
550 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
554 The sequence `$0' is replace by the original filename.
555 Additionally, the sequence
556 .Ql Op Ar seq1 , Ar seq2
561 is not a null string; otherwise it is replaced by
563 For example, the command
565 .Bd -literal -offset indent -compact
566 nmap $1.$2.$3 [$1,$2].[$2,file]
570 the output filename "myfile.data" for input filenames "myfile.data" and
571 "myfile.data.old", "myfile.file" for the input filename "myfile", and
572 "myfile.myfile" for the input filename ".myfile".
573 Spaces may be included in
575 as in the example: `nmap $1 sed "s/ *$//" \*[Gt] $1' .
576 Use the `\e' character to prevent special treatment
577 of the `$','[','[', and `,' characters.
578 .It Ic ntrans Op Ar inchars Op Ar outchars
579 Set or unset the filename character translation mechanism.
580 If no arguments are specified, the filename character
581 translation mechanism is unset.
582 If arguments are specified, characters in
583 remote filenames are translated during
587 commands issued without a specified remote target filename.
588 If arguments are specified, characters in
589 local filenames are translated during
593 commands issued without a specified local target filename.
594 This command is useful when connecting to a
597 with different file naming conventions or practices.
598 Characters in a filename matching a character in
600 are replaced with the corresponding character in
602 If the character's position in
604 is longer than the length of
606 the character is deleted from the file name.
607 .It Ic open Ar host Op Ar port
608 Establish a connection to the specified
612 An optional port number may be supplied,
615 will attempt to contact an
620 option is on (default),
622 will also attempt to automatically log the user in to
627 Toggle passive mode. If passive mode is turned on
628 (default is off), the ftp client will
631 command for all data connections instead of the usual
635 command requests that the remote server open a port for the data connection
636 and return the address of that port. The remote server listens on that
637 port and the client connects to it. When using the more traditional
639 command, the client listens on a port and sends that address to the remote
640 server, who connects back to it. Passive mode is useful when using
642 through a gateway router or host that controls the directionality of
644 (Note that though ftp servers are required to support the
646 command by RFC 1123, some do not.)
648 Toggle interactive prompting.
649 Interactive prompting
650 occurs during multiple file transfers to allow the
651 user to selectively retrieve or store files.
652 If prompting is turned off (default is on), any
656 will transfer all files, and any
658 will delete all files.
659 .It Ic proxy Ar ftp-command
660 Execute an ftp command on a secondary control connection.
661 This command allows simultaneous connection to two remote ftp
662 servers for transferring files between the two servers.
667 to establish the secondary control connection.
668 Enter the command "proxy ?" to see other ftp commands executable on the
669 secondary connection.
670 The following commands behave differently when prefaced by
673 will not define new macros during the auto-login process,
675 will not erase existing macro definitions,
679 transfer files from the host on the primary control connection
680 to the host on the secondary control connection, and
685 transfer files from the host on the secondary control connection
686 to the host on the primary control connection.
687 Third party file transfers depend upon support of the ftp protocol
689 command by the server on the secondary control connection.
690 .It Ic put Ar local-file Op Ar remote-file
691 Store a local file on the remote machine.
694 is left unspecified, the local file name is used
695 after processing according to any
700 in naming the remote file.
701 File transfer uses the
709 Print the name of the current working directory on the remote
714 .It Ic quote Ar arg1 arg2 ...
715 The arguments specified are sent, verbatim, to the remote
718 .It Ic recv Ar remote-file Op Ar local-file
720 .It Ic reget Ar remote-file Op Ar local-file
721 Reget acts like get, except that if
728 a partially transferred copy of
731 is continued from the apparent point of failure.
733 is useful when transferring very large files over networks that
734 are prone to dropping connections.
735 .It Ic remotehelp Op Ar command-name
736 Request help from the remote
741 is specified it is supplied to the server as well.
742 .It Ic remotestatus Op Ar file-name
743 With no arguments, show status of remote machine.
746 is specified, show status of
756 on the remote machine, to the file
760 This command re-synchronizes command/reply sequencing with the remote
762 Resynchronization may be necessary following a violation of the ftp protocol
763 by the remote server.
764 .It Ic restart Ar marker
765 Restart the immediately following
774 systems, marker is usually a byte
775 offset into the file.
776 .It Ic rmdir Ar directory-name
777 Delete a directory on the remote machine.
779 Toggle storing of files on the local system with unique filenames.
780 If a file already exists with a name equal to the target
785 command, a ".1" is appended to the name.
786 If the resulting name matches another existing file,
787 a ".2" is appended to the original name.
788 If this process continues up to ".99", an error
789 message is printed, and the transfer does not take place.
790 The generated unique filename will be reported.
793 will not affect local files generated from a shell command
795 The default value is off.
796 .It Ic send Ar local-file Op Ar remote-file
804 will attempt to use a
806 command when establishing
807 a connection for each data transfer.
810 commands can prevent delays
811 when performing multiple file transfers.
816 will use the default data port.
819 commands is disabled, no attempt will be made to use
821 commands for each data transfer.
825 implementations which do ignore
827 commands but, incorrectly, indicate they've been accepted.
828 .It Ic site Ar arg1 arg2 ...
829 The arguments specified are sent, verbatim, to the remote
834 .It Ic size Ar file-name
839 Show the current status of
841 .It Ic struct Op Ar struct-name
842 Set the file transfer
846 By default \*(Lqstream\*(Rq structure is used.
848 Toggle storing of files on remote machine under unique file names.
849 Remote ftp server must support ftp protocol
852 successful completion.
853 The remote server will report unique name.
854 Default value is off.
856 Show the type of operating system running on the remote machine.
858 Set the file transfer type to that needed to
863 Toggle packet tracing.
864 .It Ic type Op Ar type-name
865 Set the file transfer
869 If no type is specified, the current type
871 The default type is network
873 .It Ic umask Op Ar newmask
874 Set the default umask on the remote server to
878 is omitted, the current umask is printed.
880 .Ic user Ar user-name
884 Identify yourself to the remote
889 is not specified and the server requires it,
891 will prompt the user for it (after disabling local echo).
894 field is not specified, and the
897 requires it, the user will be prompted for it.
900 field is specified, an account command will
901 be relayed to the remote server after the login sequence
902 is completed if the remote server did not require it
906 is invoked with \*(Lqauto-login\*(Rq disabled, this
907 process is done automatically on initial connection to
913 In verbose mode, all responses from
916 server are displayed to the user.
918 if verbose is on, when a file transfer completes, statistics
919 regarding the efficiency of the transfer are reported.
922 .It Ic \&? Op Ar command
926 The following command can be used with ftpsec-aware servers.
935 Set the data protection level to the requested level.
938 The following command can be used with ftp servers that has
939 implemented the KAUTH site command.
941 .It Ic kauth Op Ar principal
942 Obtain remote tickets.
945 Command arguments which have embedded spaces may be quoted with
947 .Sh ABORTING A FILE TRANSFER
948 To abort a file transfer, use the terminal interrupt key
950 Sending transfers will be immediately halted.
951 Receiving transfers will be halted by sending a ftp protocol
953 command to the remote server, and discarding any further data received.
954 The speed at which this is accomplished depends upon the remote
958 If the remote server does not support the
962 prompt will not appear until the remote server has completed
963 sending the requested file.
965 The terminal interrupt key sequence will be ignored when
967 has completed any local processing and is awaiting a reply
968 from the remote server.
969 A long delay in this mode may result from the ABOR processing described
970 above, or from unexpected behavior by the remote server, including
971 violations of the ftp protocol.
972 If the delay results from unexpected remote server behavior, the local
974 program must be killed by hand.
975 .Sh FILE NAMING CONVENTIONS
976 Files specified as arguments to
978 commands are processed according to the following rules.
987 (for writing) is used.
989 If the first character of the file name is
992 remainder of the argument is interpreted as a shell command.
994 then forks a shell, using
996 with the argument supplied, and reads (writes) from the stdout
998 If the shell command includes spaces, the argument
1000 \*(Lq" ls -lt"\*(Rq.
1002 useful example of this mechanism is: \*(Lqdir more\*(Rq.
1004 Failing the above checks, if ``globbing'' is enabled,
1005 local file names are expanded
1006 according to the rules used in the
1013 command expects a single local file (.e.g.
1015 only the first filename generated by the "globbing" operation is used.
1021 commands with unspecified local file names, the local filename is
1022 the remote filename, which may be altered by a
1028 The resulting filename may then be altered if
1036 commands with unspecified remote file names, the remote filename is
1037 the local filename, which may be altered by a
1042 The resulting filename may then be altered by the remote server if
1046 .Sh FILE TRANSFER PARAMETERS
1047 The FTP specification specifies many parameters which may
1048 affect a file transfer.
1051 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1052 \*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for
1058 supports the ascii and image types of file transfer,
1059 plus local byte size 8 for
1064 supports only the default values for the remaining
1065 file transfer parameters:
1073 file contains login and initialization information
1074 used by the auto-login process.
1075 It resides in the user's home directory.
1076 The following tokens are recognized; they may be separated by spaces,
1078 .Bl -tag -width password
1079 .It Ic machine Ar name
1080 Identify a remote machine
1082 The auto-login process searches the
1086 token that matches the remote machine specified on the
1088 command line or as an
1091 Once a match is made, the subsequent
1093 tokens are processed,
1094 stopping when the end of file is reached or another
1098 token is encountered.
1106 There can be only one
1108 token, and it must be after all
1111 This is normally used as:
1113 .Dl default login anonymous password user@site
1115 thereby giving the user
1117 anonymous ftp login to
1118 machines not specified in
1120 This can be overridden
1123 flag to disable auto-login.
1124 .It Ic login Ar name
1125 Identify a user on the remote machine.
1126 If this token is present, the auto-login process will initiate
1127 a login using the specified
1129 .It Ic password Ar string
1131 If this token is present, the auto-login process will supply the
1132 specified string if the remote server requires a password as part
1133 of the login process.
1134 Note that if this token is present in the
1136 file for any user other
1140 will abort the auto-login process if the
1143 anyone besides the user.
1144 .It Ic account Ar string
1145 Supply an additional account password.
1146 If this token is present, the auto-login process will supply the
1147 specified string if the remote server requires an additional
1148 account password, or the auto-login process will initiate an
1150 command if it does not.
1151 .It Ic macdef Ar name
1153 This token functions like the
1157 A macro is defined with the specified name; its contents begin with the
1160 line and continue until a null line (consecutive new-line
1161 characters) is encountered.
1164 is defined, it is automatically executed as the last step in the
1169 uses the following environment variables.
1172 For default location of a
1174 file, if one exists.
1189 Correct execution of many commands depends upon proper behavior
1190 by the remote server.
1192 An error in the treatment of carriage returns
1195 ascii-mode transfer code
1197 This correction may result in incorrect transfers of binary files
1200 servers using the ascii type.
1201 Avoid this problem by using the binary image type.