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
56 is the user interface to the
58 standard File Transfer Protocol.
59 The program allows a user to transfer files to and from a
62 Modifications has been made so that it almost follows the ftpsec
65 Options may be specified at the command line, or to the
69 Enables packet tracing.
73 to show all responses from the remote server, as well
74 as report on data transfer statistics.
78 from attempting \*(Lqauto-login\*(Rq upon initial connection.
79 If auto-login is enabled,
83 (see below) file in the user's home directory for an entry describing
84 an account on the remote machine.
87 will prompt for the remote machine login name (default is the user
88 identity on the local machine), and, if necessary, prompt for a password
89 and an account with which to login.
91 Turns off interactive prompting during
92 multiple file transfers.
98 Disables file name globbing.
101 The client host with which
103 is to communicate may be specified on the command line.
106 will immediately attempt to establish a connection to an
108 server on that host; otherwise,
110 will enter its command interpreter and await instructions
114 is awaiting commands from the user the prompt
116 is provided to the user.
117 The following commands are recognized
121 .It Ic \&! Op Ar command Op Ar args
122 Invoke an interactive shell on the local machine.
123 If there are arguments, the first is taken to be a command to execute
124 directly, with the rest of the arguments as its arguments.
125 .It Ic \&$ Ar macro-name Op Ar args
128 that was defined with the
131 Arguments are passed to the macro unglobbed.
132 .It Ic account Op Ar passwd
133 Supply a supplemental password required by a remote system for access
134 to resources once a login has been successfully completed.
135 If no argument is included, the user will be prompted for an account
136 password in a non-echoing input mode.
137 .It Ic append Ar local-file Op Ar remote-file
138 Append a local file to a file on the remote machine.
141 is left unspecified, the local file name is used in naming the
142 remote file after being altered by any
147 File transfer uses the current settings for
154 Set the file transfer
158 This is the default type.
160 Arrange that a bell be sounded after each file transfer
161 command is completed.
163 Set the file transfer
165 to support binary image transfer.
169 session with the remote server
172 An end of file will also terminate the session and exit.
174 Toggle remote computer file name case mapping during
179 is on (default is off), remote computer file names with all letters in
180 upper case are written in the local directory with the letters mapped
182 .It Ic \&cd Ar remote-directory
183 Change the working directory on the remote machine
185 .Ar remote-directory .
187 Change the remote machine working directory to the parent of the
188 current remote machine working directory.
189 .It Ic chmod Ar mode file-name
190 Change the permission modes of the file
198 session with the remote server, and
199 return to the command interpreter.
200 Any defined macros are erased.
202 Toggle carriage return stripping during
203 ascii type file retrieval.
204 Records are denoted by a carriage return/linefeed sequence
205 during ascii type file transfer.
208 is on (the default), carriage returns are stripped from this
209 sequence to conform with the
211 single linefeed record
215 remote systems may contain single linefeeds;
216 when an ascii type transfer is made, these linefeeds may be
217 distinguished from a record delimiter only when
220 .It Ic delete Ar remote-file
223 on the remote machine.
224 .It Ic debug Op Ar debug-value
225 Toggle debugging mode.
228 is specified it is used to set the debugging level.
229 When debugging is on,
231 prints each command sent to the remote machine, preceded
236 .Op Ar remote-directory
239 Print a listing of the directory contents in the
241 .Ar remote-directory ,
242 and, optionally, placing the output in
244 If interactive prompting is on,
246 will prompt the user to verify that the last argument is indeed the
247 target local file for receiving
250 If no directory is specified, the current working
251 directory on the remote machine is used.
253 file is specified, or
257 output comes to the terminal.
261 .It Ic form Ar format
262 Set the file transfer
266 The default format is \*(Lqfile\*(Rq.
267 .It Ic get Ar remote-file Op Ar local-file
270 and store it on the local machine.
272 file name is not specified, it is given the same
273 name it has on the remote machine, subject to
274 alteration by the current
280 The current settings for
286 are used while transferring the file.
288 Toggle filename expansion for
293 If globbing is turned off with
295 the file name arguments
296 are taken literally and not expanded.
305 each remote file name is expanded
306 separately on the remote machine and the lists are not merged.
307 Expansion of a directory name is likely to be
308 different from expansion of the name of an ordinary file:
309 the exact result depends on the foreign operating system and ftp server,
310 and can be previewed by doing
311 .Ql mls remote-files \- .
312 As a security measure, remotely globbed files that starts with
316 will not be automatically received. If you have interactive prompting
317 turned off, these filenames will be ignored. Note:
321 are not meant to transfer
322 entire directory subtrees of files.
326 archive of the subtree (in binary mode).
328 Toggle hash-sign (``#'') printing for each data block
330 The size of a data block is 1024 bytes.
331 .It Ic help Op Ar command
332 Print an informative message about the meaning of
334 If no argument is given,
336 prints a list of the known commands.
337 .It Ic idle Op Ar seconds
338 Set the inactivity timer on the remote server to
343 is omitted, the current inactivity timer is printed.
344 .It Ic lcd Op Ar directory
345 Change the working directory on the local machine.
349 is specified, the user's home directory is used.
352 .Op Ar remote-directory
355 Print a listing of the contents of a
356 directory on the remote machine.
357 The listing includes any system-dependent information that the server
358 chooses to include; for example, most
361 output from the command
367 is left unspecified, the current working directory is used.
368 If interactive prompting is on,
370 will prompt the user to verify that the last argument is indeed the
371 target local file for receiving
374 If no local file is specified, or if
378 the output is sent to the terminal.
379 .It Ic macdef Ar macro-name
381 Subsequent lines are stored as the macro
383 a null line (consecutive newline characters
385 carriage returns from the terminal) terminates macro input mode.
386 There is a limit of 16 macros and 4096 total characters in all
388 Macros remain defined until a
391 The macro processor interprets `$' and `\e' as special characters.
392 A `$' followed by a number (or numbers) is replaced by the
393 corresponding argument on the macro invocation command line.
394 A `$' followed by an `i' signals that macro processor that the
395 executing macro is to be looped.
396 On the first pass `$i' is
397 replaced by the first argument on the macro invocation command line,
398 on the second pass it is replaced by the second argument, and so on.
399 A `\e' followed by any character is replaced by that character.
400 Use the `\e' to prevent special treatment of the `$'.
401 .It Ic mdelete Op Ar remote-files
404 on the remote machine.
405 .It Ic mdir Ar remote-files local-file
408 except multiple remote files may be specified.
409 If interactive prompting is on,
411 will prompt the user to verify that the last argument is indeed the
412 target local file for receiving
415 .It Ic mget Ar remote-files
418 on the remote machine
421 for each file name thus produced.
424 for details on the filename expansion.
425 Resulting file names will then be processed according to
431 Files are transferred into the local working directory,
432 which can be changed with
434 new local directories can be created with
435 .Ql "\&! mkdir directory" .
436 .It Ic mkdir Ar directory-name
437 Make a directory on the remote machine.
438 .It Ic mls Ar remote-files local-file
441 except multiple remote files may be specified,
445 If interactive prompting is on,
447 will prompt the user to verify that the last argument is indeed the
448 target local file for receiving
451 .It Ic mode Op Ar mode-name
452 Set the file transfer
456 The default mode is \*(Lqstream\*(Rq mode.
457 .It Ic modtime Ar file-name
458 Show the last modification time of the file on the remote machine.
459 .It Ic mput Ar local-files
460 Expand wild cards in the list of local files given as arguments
463 for each file in the resulting list.
466 for details of filename expansion.
467 Resulting file names will then be processed according to
472 .It Ic newer Ar file-name
473 Get the file only if the modification time of the remote file is more
474 recent that the file on the current system.
476 exist on the current system, the remote file is considered
478 Otherwise, this command is identical to
482 .Op Ar remote-directory
485 Print a list of the files in a
486 directory on the remote machine.
489 is left unspecified, the current working directory is used.
490 If interactive prompting is on,
492 will prompt the user to verify that the last argument is indeed the
493 target local file for receiving
496 If no local file is specified, or if
500 the output is sent to the terminal.
501 .It Ic nmap Op Ar inpattern outpattern
502 Set or unset the filename mapping mechanism.
503 If no arguments are specified, the filename mapping mechanism is unset.
504 If arguments are specified, remote filenames are mapped during
508 commands issued without a specified remote target filename.
509 If arguments are specified, local filenames are mapped during
513 commands issued without a specified local target filename.
514 This command is useful when connecting to a
517 with different file naming conventions or practices.
518 The mapping follows the pattern set by
523 is a template for incoming filenames (which may have already been
524 processed according to the
529 Variable templating is accomplished by including the
530 sequences `$1', `$2', ..., `$9' in
532 Use `\\' to prevent this special treatment of the `$' character.
533 All other characters are treated literally, and are used to determine the
539 $1.$2 and the remote file name "mydata.data", $1 would have the value
540 "mydata", and $2 would have the value "data".
543 determines the resulting mapped filename.
544 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
548 The sequence `$0' is replace by the original filename.
549 Additionally, the sequence
550 .Ql Op Ar seq1 , Ar seq2
555 is not a null string; otherwise it is replaced by
557 For example, the command
559 .Bd -literal -offset indent -compact
560 nmap $1.$2.$3 [$1,$2].[$2,file]
564 the output filename "myfile.data" for input filenames "myfile.data" and
565 "myfile.data.old", "myfile.file" for the input filename "myfile", and
566 "myfile.myfile" for the input filename ".myfile".
567 Spaces may be included in
569 as in the example: `nmap $1 sed "s/ *$//" > $1' .
570 Use the `\e' character to prevent special treatment
571 of the `$','[','[', and `,' characters.
572 .It Ic ntrans Op Ar inchars Op Ar outchars
573 Set or unset the filename character translation mechanism.
574 If no arguments are specified, the filename character
575 translation mechanism is unset.
576 If arguments are specified, characters in
577 remote filenames are translated during
581 commands issued without a specified remote target filename.
582 If arguments are specified, characters in
583 local filenames are translated during
587 commands issued without a specified local target filename.
588 This command is useful when connecting to a
591 with different file naming conventions or practices.
592 Characters in a filename matching a character in
594 are replaced with the corresponding character in
596 If the character's position in
598 is longer than the length of
600 the character is deleted from the file name.
601 .It Ic open Ar host Op Ar port
602 Establish a connection to the specified
606 An optional port number may be supplied,
609 will attempt to contact an
614 option is on (default),
616 will also attempt to automatically log the user in to
621 Toggle passive mode. If passive mode is turned on
622 (default is off), the ftp client will
625 command for all data connections instead of the usual
629 command requests that the remote server open a port for the data connection
630 and return the address of that port. The remote server listens on that
631 port and the client connects to it. When using the more traditional
633 command, the client listens on a port and sends that address to the remote
634 server, who connects back to it. Passive mode is useful when using
636 through a gateway router or host that controls the directionality of
638 (Note that though ftp servers are required to support the
640 command by RFC 1123, some do not.)
642 Toggle interactive prompting.
643 Interactive prompting
644 occurs during multiple file transfers to allow the
645 user to selectively retrieve or store files.
646 If prompting is turned off (default is on), any
650 will transfer all files, and any
652 will delete all files.
653 .It Ic proxy Ar ftp-command
654 Execute an ftp command on a secondary control connection.
655 This command allows simultaneous connection to two remote ftp
656 servers for transferring files between the two servers.
661 to establish the secondary control connection.
662 Enter the command "proxy ?" to see other ftp commands executable on the
663 secondary connection.
664 The following commands behave differently when prefaced by
667 will not define new macros during the auto-login process,
669 will not erase existing macro definitions,
673 transfer files from the host on the primary control connection
674 to the host on the secondary control connection, and
679 transfer files from the host on the secondary control connection
680 to the host on the primary control connection.
681 Third party file transfers depend upon support of the ftp protocol
683 command by the server on the secondary control connection.
684 .It Ic put Ar local-file Op Ar remote-file
685 Store a local file on the remote machine.
688 is left unspecified, the local file name is used
689 after processing according to any
694 in naming the remote file.
695 File transfer uses the
703 Print the name of the current working directory on the remote
708 .It Ic quote Ar arg1 arg2 ...
709 The arguments specified are sent, verbatim, to the remote
712 .It Ic recv Ar remote-file Op Ar local-file
714 .It Ic reget Ar remote-file Op Ar local-file
715 Reget acts like get, except that if
722 a partially transferred copy of
725 is continued from the apparent point of failure.
727 is useful when transferring very large files over networks that
728 are prone to dropping connections.
729 .It Ic remotehelp Op Ar command-name
730 Request help from the remote
735 is specified it is supplied to the server as well.
736 .It Ic remotestatus Op Ar file-name
737 With no arguments, show status of remote machine.
740 is specified, show status of
750 on the remote machine, to the file
754 This command re-synchronizes command/reply sequencing with the remote
756 Resynchronization may be necessary following a violation of the ftp protocol
757 by the remote server.
758 .It Ic restart Ar marker
759 Restart the immediately following
768 systems, marker is usually a byte
769 offset into the file.
770 .It Ic rmdir Ar directory-name
771 Delete a directory on the remote machine.
773 Toggle storing of files on the local system with unique filenames.
774 If a file already exists with a name equal to the target
779 command, a ".1" is appended to the name.
780 If the resulting name matches another existing file,
781 a ".2" is appended to the original name.
782 If this process continues up to ".99", an error
783 message is printed, and the transfer does not take place.
784 The generated unique filename will be reported.
787 will not affect local files generated from a shell command
789 The default value is off.
790 .It Ic send Ar local-file Op Ar remote-file
798 will attempt to use a
800 command when establishing
801 a connection for each data transfer.
804 commands can prevent delays
805 when performing multiple file transfers.
810 will use the default data port.
813 commands is disabled, no attempt will be made to use
815 commands for each data transfer.
819 implementations which do ignore
821 commands but, incorrectly, indicate they've been accepted.
822 .It Ic site Ar arg1 arg2 ...
823 The arguments specified are sent, verbatim, to the remote
828 .It Ic size Ar file-name
833 Show the current status of
835 .It Ic struct Op Ar struct-name
836 Set the file transfer
840 By default \*(Lqstream\*(Rq structure is used.
842 Toggle storing of files on remote machine under unique file names.
843 Remote ftp server must support ftp protocol
846 successful completion.
847 The remote server will report unique name.
848 Default value is off.
850 Show the type of operating system running on the remote machine.
852 Set the file transfer type to that needed to
857 Toggle packet tracing.
858 .It Ic type Op Ar type-name
859 Set the file transfer
863 If no type is specified, the current type
865 The default type is network
867 .It Ic umask Op Ar newmask
868 Set the default umask on the remote server to
872 is omitted, the current umask is printed.
874 .Ic user Ar user-name
878 Identify yourself to the remote
883 is not specified and the server requires it,
885 will prompt the user for it (after disabling local echo).
888 field is not specified, and the
891 requires it, the user will be prompted for it.
894 field is specified, an account command will
895 be relayed to the remote server after the login sequence
896 is completed if the remote server did not require it
900 is invoked with \*(Lqauto-login\*(Rq disabled, this
901 process is done automatically on initial connection to
907 In verbose mode, all responses from
910 server are displayed to the user.
912 if verbose is on, when a file transfer completes, statistics
913 regarding the efficiency of the transfer are reported.
916 .It Ic ? Op Ar command
920 The following command can be used with ftpsec-aware servers.
929 Set the data protection level to the requested level.
932 The following command can be used with ftp servers that has
933 implemented the KAUTH site command.
935 .It Ic kauth Op Ar principal
936 Obtain remote tickets.
939 Command arguments which have embedded spaces may be quoted with
941 .Sh ABORTING A FILE TRANSFER
942 To abort a file transfer, use the terminal interrupt key
944 Sending transfers will be immediately halted.
945 Receiving transfers will be halted by sending a ftp protocol
947 command to the remote server, and discarding any further data received.
948 The speed at which this is accomplished depends upon the remote
952 If the remote server does not support the
956 prompt will not appear until the remote server has completed
957 sending the requested file.
959 The terminal interrupt key sequence will be ignored when
961 has completed any local processing and is awaiting a reply
962 from the remote server.
963 A long delay in this mode may result from the ABOR processing described
964 above, or from unexpected behavior by the remote server, including
965 violations of the ftp protocol.
966 If the delay results from unexpected remote server behavior, the local
968 program must be killed by hand.
969 .Sh FILE NAMING CONVENTIONS
970 Files specified as arguments to
972 commands are processed according to the following rules.
981 (for writing) is used.
983 If the first character of the file name is
986 remainder of the argument is interpreted as a shell command.
988 then forks a shell, using
990 with the argument supplied, and reads (writes) from the stdout
992 If the shell command includes spaces, the argument
996 useful example of this mechanism is: \*(Lqdir more\*(Rq.
998 Failing the above checks, if ``globbing'' is enabled,
999 local file names are expanded
1000 according to the rules used in the
1007 command expects a single local file (.e.g.
1009 only the first filename generated by the "globbing" operation is used.
1015 commands with unspecified local file names, the local filename is
1016 the remote filename, which may be altered by a
1022 The resulting filename may then be altered if
1030 commands with unspecified remote file names, the remote filename is
1031 the local filename, which may be altered by a
1036 The resulting filename may then be altered by the remote server if
1040 .Sh FILE TRANSFER PARAMETERS
1041 The FTP specification specifies many parameters which may
1042 affect a file transfer.
1045 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1046 \*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for
1052 supports the ascii and image types of file transfer,
1053 plus local byte size 8 for
1058 supports only the default values for the remaining
1059 file transfer parameters:
1067 file contains login and initialization information
1068 used by the auto-login process.
1069 It resides in the user's home directory.
1070 The following tokens are recognized; they may be separated by spaces,
1072 .Bl -tag -width password
1073 .It Ic machine Ar name
1074 Identify a remote machine
1076 The auto-login process searches the
1080 token that matches the remote machine specified on the
1082 command line or as an
1085 Once a match is made, the subsequent
1087 tokens are processed,
1088 stopping when the end of file is reached or another
1092 token is encountered.
1100 There can be only one
1102 token, and it must be after all
1105 This is normally used as:
1107 .Dl default login anonymous password user@site
1109 thereby giving the user
1111 anonymous ftp login to
1112 machines not specified in
1114 This can be overridden
1117 flag to disable auto-login.
1118 .It Ic login Ar name
1119 Identify a user on the remote machine.
1120 If this token is present, the auto-login process will initiate
1121 a login using the specified
1123 .It Ic password Ar string
1125 If this token is present, the auto-login process will supply the
1126 specified string if the remote server requires a password as part
1127 of the login process.
1128 Note that if this token is present in the
1130 file for any user other
1134 will abort the auto-login process if the
1137 anyone besides the user.
1138 .It Ic account Ar string
1139 Supply an additional account password.
1140 If this token is present, the auto-login process will supply the
1141 specified string if the remote server requires an additional
1142 account password, or the auto-login process will initiate an
1144 command if it does not.
1145 .It Ic macdef Ar name
1147 This token functions like the
1151 A macro is defined with the specified name; its contents begin with the
1154 line and continue until a null line (consecutive new-line
1155 characters) is encountered.
1158 is defined, it is automatically executed as the last step in the
1163 utilizes the following environment variables.
1166 For default location of a
1168 file, if one exists.
1181 Correct execution of many commands depends upon proper behavior
1182 by the remote server.
1184 An error in the treatment of carriage returns
1187 ascii-mode transfer code
1189 This correction may result in incorrect transfers of binary files
1192 servers using the ascii type.
1193 Avoid this problem by using the binary image type.