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
57 is the user interface to the
59 standard File Transfer Protocol.
60 The program allows a user to transfer files to and from a
63 Modifications has been made so that it almost follows the ftpsec
66 Options may be specified at the command line, or to the
70 Enables packet tracing.
74 to show all responses from the remote server, as well
75 as report on data transfer statistics.
79 from attempting \*(Lqauto-login\*(Rq upon initial connection.
80 If auto-login is enabled,
84 (see below) file in the user's home directory for an entry describing
85 an account on the remote machine.
88 will prompt for the remote machine login name (default is the user
89 identity on the local machine), and, if necessary, prompt for a password
90 and an account with which to login.
92 Turns off interactive prompting during
93 multiple file transfers.
99 Disables file name globbing.
101 Disables command line editing.
104 The client host with which
106 is to communicate may be specified on the command line.
109 will immediately attempt to establish a connection to an
111 server on that host; otherwise,
113 will enter its command interpreter and await instructions
117 is awaiting commands from the user the prompt
119 is provided to the user.
120 The following commands are recognized
124 .It Ic \&! Op Ar command Op Ar args
125 Invoke an interactive shell on the local machine.
126 If there are arguments, the first is taken to be a command to execute
127 directly, with the rest of the arguments as its arguments.
128 .It Ic \&$ Ar macro-name Op Ar args
131 that was defined with the
134 Arguments are passed to the macro unglobbed.
135 .It Ic account Op Ar passwd
136 Supply a supplemental password required by a remote system for access
137 to resources once a login has been successfully completed.
138 If no argument is included, the user will be prompted for an account
139 password in a non-echoing input mode.
140 .It Ic append Ar local-file Op Ar remote-file
141 Append a local file to a file on the remote machine.
144 is left unspecified, the local file name is used in naming the
145 remote file after being altered by any
150 File transfer uses the current settings for
157 Set the file transfer
161 This is the default type.
163 Arrange that a bell be sounded after each file transfer
164 command is completed.
166 Set the file transfer
168 to support binary image transfer.
172 session with the remote server
175 An end of file will also terminate the session and exit.
177 Toggle remote computer file name case mapping during
182 is on (default is off), remote computer file names with all letters in
183 upper case are written in the local directory with the letters mapped
185 .It Ic \&cd Ar remote-directory
186 Change the working directory on the remote machine
188 .Ar remote-directory .
190 Change the remote machine working directory to the parent of the
191 current remote machine working directory.
192 .It Ic chmod Ar mode file-name
193 Change the permission modes of the file
201 session with the remote server, and
202 return to the command interpreter.
203 Any defined macros are erased.
205 Toggle carriage return stripping during
206 ascii type file retrieval.
207 Records are denoted by a carriage return/linefeed sequence
208 during ascii type file transfer.
211 is on (the default), carriage returns are stripped from this
212 sequence to conform with the
214 single linefeed record
218 remote systems may contain single linefeeds;
219 when an ascii type transfer is made, these linefeeds may be
220 distinguished from a record delimiter only when
223 .It Ic delete Ar remote-file
226 on the remote machine.
227 .It Ic debug Op Ar debug-value
228 Toggle debugging mode.
231 is specified it is used to set the debugging level.
232 When debugging is on,
234 prints each command sent to the remote machine, preceded
239 .Op Ar remote-directory
242 Print a listing of the directory contents in the
244 .Ar remote-directory ,
245 and, optionally, placing the output in
247 If interactive prompting is on,
249 will prompt the user to verify that the last argument is indeed the
250 target local file for receiving
253 If no directory is specified, the current working
254 directory on the remote machine is used.
256 file is specified, or
260 output comes to the terminal.
264 .It Ic form Ar format
265 Set the file transfer
269 The default format is \*(Lqfile\*(Rq.
270 .It Ic get Ar remote-file Op Ar local-file
273 and store it on the local machine.
275 file name is not specified, it is given the same
276 name it has on the remote machine, subject to
277 alteration by the current
283 The current settings for
289 are used while transferring the file.
291 Toggle filename expansion for
296 If globbing is turned off with
298 the file name arguments
299 are taken literally and not expanded.
308 each remote file name is expanded
309 separately on the remote machine and the lists are not merged.
310 Expansion of a directory name is likely to be
311 different from expansion of the name of an ordinary file:
312 the exact result depends on the foreign operating system and ftp server,
313 and can be previewed by doing
314 .Ql mls remote-files \- .
315 As a security measure, remotely globbed files that starts with
319 will not be automatically received. If you have interactive prompting
320 turned off, these filenames will be ignored. Note:
324 are not meant to transfer
325 entire directory subtrees of files.
329 archive of the subtree (in binary mode).
331 Toggle hash-sign (``#'') printing for each data block
333 The size of a data block is 1024 bytes.
334 .It Ic help Op Ar command
335 Print an informative message about the meaning of
337 If no argument is given,
339 prints a list of the known commands.
340 .It Ic idle Op Ar seconds
341 Set the inactivity timer on the remote server to
346 is omitted, the current inactivity timer is printed.
347 .It Ic lcd Op Ar directory
348 Change the working directory on the local machine.
352 is specified, the user's home directory is used.
355 .Op Ar remote-directory
358 Print a listing of the contents of a
359 directory on the remote machine.
360 The listing includes any system-dependent information that the server
361 chooses to include; for example, most
364 output from the command
370 is left unspecified, the current working directory is used.
371 If interactive prompting is on,
373 will prompt the user to verify that the last argument is indeed the
374 target local file for receiving
377 If no local file is specified, or if
381 the output is sent to the terminal.
382 .It Ic macdef Ar macro-name
384 Subsequent lines are stored as the macro
386 a null line (consecutive newline characters
388 carriage returns from the terminal) terminates macro input mode.
389 There is a limit of 16 macros and 4096 total characters in all
391 Macros remain defined until a
394 The macro processor interprets `$' and `\e' as special characters.
395 A `$' followed by a number (or numbers) is replaced by the
396 corresponding argument on the macro invocation command line.
397 A `$' followed by an `i' signals that macro processor that the
398 executing macro is to be looped.
399 On the first pass `$i' is
400 replaced by the first argument on the macro invocation command line,
401 on the second pass it is replaced by the second argument, and so on.
402 A `\e' followed by any character is replaced by that character.
403 Use the `\e' to prevent special treatment of the `$'.
404 .It Ic mdelete Op Ar remote-files
407 on the remote machine.
408 .It Ic mdir Ar remote-files local-file
411 except multiple remote files may be specified.
412 If interactive prompting is on,
414 will prompt the user to verify that the last argument is indeed the
415 target local file for receiving
418 .It Ic mget Ar remote-files
421 on the remote machine
424 for each file name thus produced.
427 for details on the filename expansion.
428 Resulting file names will then be processed according to
434 Files are transferred into the local working directory,
435 which can be changed with
437 new local directories can be created with
438 .Ql "\&! mkdir directory" .
439 .It Ic mkdir Ar directory-name
440 Make a directory on the remote machine.
441 .It Ic mls Ar remote-files local-file
444 except multiple remote files may be specified,
448 If interactive prompting is on,
450 will prompt the user to verify that the last argument is indeed the
451 target local file for receiving
454 .It Ic mode Op Ar mode-name
455 Set the file transfer
459 The default mode is \*(Lqstream\*(Rq mode.
460 .It Ic modtime Ar file-name
461 Show the last modification time of the file on the remote machine.
462 .It Ic mput Ar local-files
463 Expand wild cards in the list of local files given as arguments
466 for each file in the resulting list.
469 for details of filename expansion.
470 Resulting file names will then be processed according to
475 .It Ic newer Ar file-name
476 Get the file only if the modification time of the remote file is more
477 recent that the file on the current system.
479 exist on the current system, the remote file is considered
481 Otherwise, this command is identical to
485 .Op Ar remote-directory
488 Print a list of the files in a
489 directory on the remote machine.
492 is left unspecified, the current working directory is used.
493 If interactive prompting is on,
495 will prompt the user to verify that the last argument is indeed the
496 target local file for receiving
499 If no local file is specified, or if
503 the output is sent to the terminal.
504 .It Ic nmap Op Ar inpattern outpattern
505 Set or unset the filename mapping mechanism.
506 If no arguments are specified, the filename mapping mechanism is unset.
507 If arguments are specified, remote filenames are mapped during
511 commands issued without a specified remote target filename.
512 If arguments are specified, local filenames are mapped during
516 commands issued without a specified local target filename.
517 This command is useful when connecting to a
520 with different file naming conventions or practices.
521 The mapping follows the pattern set by
526 is a template for incoming filenames (which may have already been
527 processed according to the
532 Variable templating is accomplished by including the
533 sequences `$1', `$2', ..., `$9' in
535 Use `\\' to prevent this special treatment of the `$' character.
536 All other characters are treated literally, and are used to determine the
542 $1.$2 and the remote file name "mydata.data", $1 would have the value
543 "mydata", and $2 would have the value "data".
546 determines the resulting mapped filename.
547 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
551 The sequence `$0' is replace by the original filename.
552 Additionally, the sequence
553 .Ql Op Ar seq1 , Ar seq2
558 is not a null string; otherwise it is replaced by
560 For example, the command
562 .Bd -literal -offset indent -compact
563 nmap $1.$2.$3 [$1,$2].[$2,file]
567 the output filename "myfile.data" for input filenames "myfile.data" and
568 "myfile.data.old", "myfile.file" for the input filename "myfile", and
569 "myfile.myfile" for the input filename ".myfile".
570 Spaces may be included in
572 as in the example: `nmap $1 sed "s/ *$//" > $1' .
573 Use the `\e' character to prevent special treatment
574 of the `$','[','[', and `,' characters.
575 .It Ic ntrans Op Ar inchars Op Ar outchars
576 Set or unset the filename character translation mechanism.
577 If no arguments are specified, the filename character
578 translation mechanism is unset.
579 If arguments are specified, characters in
580 remote filenames are translated during
584 commands issued without a specified remote target filename.
585 If arguments are specified, characters in
586 local filenames are translated during
590 commands issued without a specified local target filename.
591 This command is useful when connecting to a
594 with different file naming conventions or practices.
595 Characters in a filename matching a character in
597 are replaced with the corresponding character in
599 If the character's position in
601 is longer than the length of
603 the character is deleted from the file name.
604 .It Ic open Ar host Op Ar port
605 Establish a connection to the specified
609 An optional port number may be supplied,
612 will attempt to contact an
617 option is on (default),
619 will also attempt to automatically log the user in to
624 Toggle passive mode. If passive mode is turned on
625 (default is off), the ftp client will
628 command for all data connections instead of the usual
632 command requests that the remote server open a port for the data connection
633 and return the address of that port. The remote server listens on that
634 port and the client connects to it. When using the more traditional
636 command, the client listens on a port and sends that address to the remote
637 server, who connects back to it. Passive mode is useful when using
639 through a gateway router or host that controls the directionality of
641 (Note that though ftp servers are required to support the
643 command by RFC 1123, some do not.)
645 Toggle interactive prompting.
646 Interactive prompting
647 occurs during multiple file transfers to allow the
648 user to selectively retrieve or store files.
649 If prompting is turned off (default is on), any
653 will transfer all files, and any
655 will delete all files.
656 .It Ic proxy Ar ftp-command
657 Execute an ftp command on a secondary control connection.
658 This command allows simultaneous connection to two remote ftp
659 servers for transferring files between the two servers.
664 to establish the secondary control connection.
665 Enter the command "proxy ?" to see other ftp commands executable on the
666 secondary connection.
667 The following commands behave differently when prefaced by
670 will not define new macros during the auto-login process,
672 will not erase existing macro definitions,
676 transfer files from the host on the primary control connection
677 to the host on the secondary control connection, and
682 transfer files from the host on the secondary control connection
683 to the host on the primary control connection.
684 Third party file transfers depend upon support of the ftp protocol
686 command by the server on the secondary control connection.
687 .It Ic put Ar local-file Op Ar remote-file
688 Store a local file on the remote machine.
691 is left unspecified, the local file name is used
692 after processing according to any
697 in naming the remote file.
698 File transfer uses the
706 Print the name of the current working directory on the remote
711 .It Ic quote Ar arg1 arg2 ...
712 The arguments specified are sent, verbatim, to the remote
715 .It Ic recv Ar remote-file Op Ar local-file
717 .It Ic reget Ar remote-file Op Ar local-file
718 Reget acts like get, except that if
725 a partially transferred copy of
728 is continued from the apparent point of failure.
730 is useful when transferring very large files over networks that
731 are prone to dropping connections.
732 .It Ic remotehelp Op Ar command-name
733 Request help from the remote
738 is specified it is supplied to the server as well.
739 .It Ic remotestatus Op Ar file-name
740 With no arguments, show status of remote machine.
743 is specified, show status of
753 on the remote machine, to the file
757 This command re-synchronizes command/reply sequencing with the remote
759 Resynchronization may be necessary following a violation of the ftp protocol
760 by the remote server.
761 .It Ic restart Ar marker
762 Restart the immediately following
771 systems, marker is usually a byte
772 offset into the file.
773 .It Ic rmdir Ar directory-name
774 Delete a directory on the remote machine.
776 Toggle storing of files on the local system with unique filenames.
777 If a file already exists with a name equal to the target
782 command, a ".1" is appended to the name.
783 If the resulting name matches another existing file,
784 a ".2" is appended to the original name.
785 If this process continues up to ".99", an error
786 message is printed, and the transfer does not take place.
787 The generated unique filename will be reported.
790 will not affect local files generated from a shell command
792 The default value is off.
793 .It Ic send Ar local-file Op Ar remote-file
801 will attempt to use a
803 command when establishing
804 a connection for each data transfer.
807 commands can prevent delays
808 when performing multiple file transfers.
813 will use the default data port.
816 commands is disabled, no attempt will be made to use
818 commands for each data transfer.
822 implementations which do ignore
824 commands but, incorrectly, indicate they've been accepted.
825 .It Ic site Ar arg1 arg2 ...
826 The arguments specified are sent, verbatim, to the remote
831 .It Ic size Ar file-name
836 Show the current status of
838 .It Ic struct Op Ar struct-name
839 Set the file transfer
843 By default \*(Lqstream\*(Rq structure is used.
845 Toggle storing of files on remote machine under unique file names.
846 Remote ftp server must support ftp protocol
849 successful completion.
850 The remote server will report unique name.
851 Default value is off.
853 Show the type of operating system running on the remote machine.
855 Set the file transfer type to that needed to
860 Toggle packet tracing.
861 .It Ic type Op Ar type-name
862 Set the file transfer
866 If no type is specified, the current type
868 The default type is network
870 .It Ic umask Op Ar newmask
871 Set the default umask on the remote server to
875 is omitted, the current umask is printed.
877 .Ic user Ar user-name
881 Identify yourself to the remote
886 is not specified and the server requires it,
888 will prompt the user for it (after disabling local echo).
891 field is not specified, and the
894 requires it, the user will be prompted for it.
897 field is specified, an account command will
898 be relayed to the remote server after the login sequence
899 is completed if the remote server did not require it
903 is invoked with \*(Lqauto-login\*(Rq disabled, this
904 process is done automatically on initial connection to
910 In verbose mode, all responses from
913 server are displayed to the user.
915 if verbose is on, when a file transfer completes, statistics
916 regarding the efficiency of the transfer are reported.
919 .It Ic \&? Op Ar command
923 The following command can be used with ftpsec-aware servers.
932 Set the data protection level to the requested level.
935 The following command can be used with ftp servers that has
936 implemented the KAUTH site command.
938 .It Ic kauth Op Ar principal
939 Obtain remote tickets.
942 Command arguments which have embedded spaces may be quoted with
944 .Sh ABORTING A FILE TRANSFER
945 To abort a file transfer, use the terminal interrupt key
947 Sending transfers will be immediately halted.
948 Receiving transfers will be halted by sending a ftp protocol
950 command to the remote server, and discarding any further data received.
951 The speed at which this is accomplished depends upon the remote
955 If the remote server does not support the
959 prompt will not appear until the remote server has completed
960 sending the requested file.
962 The terminal interrupt key sequence will be ignored when
964 has completed any local processing and is awaiting a reply
965 from the remote server.
966 A long delay in this mode may result from the ABOR processing described
967 above, or from unexpected behavior by the remote server, including
968 violations of the ftp protocol.
969 If the delay results from unexpected remote server behavior, the local
971 program must be killed by hand.
972 .Sh FILE NAMING CONVENTIONS
973 Files specified as arguments to
975 commands are processed according to the following rules.
984 (for writing) is used.
986 If the first character of the file name is
989 remainder of the argument is interpreted as a shell command.
991 then forks a shell, using
993 with the argument supplied, and reads (writes) from the stdout
995 If the shell command includes spaces, the argument
999 useful example of this mechanism is: \*(Lqdir more\*(Rq.
1001 Failing the above checks, if ``globbing'' is enabled,
1002 local file names are expanded
1003 according to the rules used in the
1010 command expects a single local file (.e.g.
1012 only the first filename generated by the "globbing" operation is used.
1018 commands with unspecified local file names, the local filename is
1019 the remote filename, which may be altered by a
1025 The resulting filename may then be altered if
1033 commands with unspecified remote file names, the remote filename is
1034 the local filename, which may be altered by a
1039 The resulting filename may then be altered by the remote server if
1043 .Sh FILE TRANSFER PARAMETERS
1044 The FTP specification specifies many parameters which may
1045 affect a file transfer.
1048 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1049 \*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for
1055 supports the ascii and image types of file transfer,
1056 plus local byte size 8 for
1061 supports only the default values for the remaining
1062 file transfer parameters:
1070 file contains login and initialization information
1071 used by the auto-login process.
1072 It resides in the user's home directory.
1073 The following tokens are recognized; they may be separated by spaces,
1075 .Bl -tag -width password
1076 .It Ic machine Ar name
1077 Identify a remote machine
1079 The auto-login process searches the
1083 token that matches the remote machine specified on the
1085 command line or as an
1088 Once a match is made, the subsequent
1090 tokens are processed,
1091 stopping when the end of file is reached or another
1095 token is encountered.
1103 There can be only one
1105 token, and it must be after all
1108 This is normally used as:
1110 .Dl default login anonymous password user@site
1112 thereby giving the user
1114 anonymous ftp login to
1115 machines not specified in
1117 This can be overridden
1120 flag to disable auto-login.
1121 .It Ic login Ar name
1122 Identify a user on the remote machine.
1123 If this token is present, the auto-login process will initiate
1124 a login using the specified
1126 .It Ic password Ar string
1128 If this token is present, the auto-login process will supply the
1129 specified string if the remote server requires a password as part
1130 of the login process.
1131 Note that if this token is present in the
1133 file for any user other
1137 will abort the auto-login process if the
1140 anyone besides the user.
1141 .It Ic account Ar string
1142 Supply an additional account password.
1143 If this token is present, the auto-login process will supply the
1144 specified string if the remote server requires an additional
1145 account password, or the auto-login process will initiate an
1147 command if it does not.
1148 .It Ic macdef Ar name
1150 This token functions like the
1154 A macro is defined with the specified name; its contents begin with the
1157 line and continue until a null line (consecutive new-line
1158 characters) is encountered.
1161 is defined, it is automatically executed as the last step in the
1166 utilizes the following environment variables.
1169 For default location of a
1171 file, if one exists.
1186 Correct execution of many commands depends upon proper behavior
1187 by the remote server.
1189 An error in the treatment of carriage returns
1192 ascii-mode transfer code
1194 This correction may result in incorrect transfers of binary files
1197 servers using the ascii type.
1198 Avoid this problem by using the binary image type.