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 .Op Fl -no-gss-bindings
57 .Op Fl -no-gss-delegate
61 is the user interface to the
63 standard File Transfer Protocol.
64 The program allows a user to transfer files to and from a
67 Modifications have been made so that it almost follows the FTP
68 Security Extensions, RFC 2228.
70 Options may be specified at the command line, or to the
74 Disable Kerberos authentication.
76 Enables packet tracing.
80 to show all responses from the remote server, as well
81 as report on data transfer statistics.
85 from attempting \*(Lqauto-login\*(Rq upon initial connection.
86 If auto-login is enabled,
90 (see below) file in the user's home directory for an entry describing
91 an account on the remote machine.
94 will prompt for the remote machine login name (default is the user
95 identity on the local machine), and, if necessary, prompt for a password
96 and an account with which to login.
98 Turns off interactive prompting during
99 multiple file transfers.
101 Turn on passive mode.
105 Disables file name globbing.
106 .It Fl -no-gss-bindings
107 Don't use GSS-API bindings when talking to peer. IP addresses will not
108 be checked to ensure they match.
109 .It Fl -no-gss-delegate
110 Disable delegation of GSSAPI credentials.
112 Disables command line editing.
114 Encrypt command and data channel.
117 The client host with which
119 is to communicate may be specified on the command line.
122 will immediately attempt to establish a connection to an
124 server on that host; otherwise,
126 will enter its command interpreter and await instructions
130 is awaiting commands from the user the prompt
132 is provided to the user.
133 The following commands are recognized
137 .It Ic \&! Op Ar command Op Ar args
138 Invoke an interactive shell on the local machine.
139 If there are arguments, the first is taken to be a command to execute
140 directly, with the rest of the arguments as its arguments.
141 .It Ic \&$ Ar macro-name Op Ar args
144 that was defined with the
147 Arguments are passed to the macro unglobbed.
148 .It Ic account Op Ar passwd
149 Supply a supplemental password required by a remote system for access
150 to resources once a login has been successfully completed.
151 If no argument is included, the user will be prompted for an account
152 password in a non-echoing input mode.
153 .It Ic append Ar local-file Op Ar remote-file
154 Append a local file to a file on the remote machine.
157 is left unspecified, the local file name is used in naming the
158 remote file after being altered by any
163 File transfer uses the current settings for
170 Set the file transfer
174 This is the default type.
176 Arrange that a bell be sounded after each file transfer
177 command is completed.
179 Set the file transfer
181 to support binary image transfer.
185 session with the remote server
188 An end of file will also terminate the session and exit.
190 Toggle remote computer file name case mapping during
195 is on (default is off), remote computer file names with all letters in
196 upper case are written in the local directory with the letters mapped
198 .It Ic \&cd Ar remote-directory
199 Change the working directory on the remote machine
201 .Ar remote-directory .
203 Change the remote machine working directory to the parent of the
204 current remote machine working directory.
205 .It Ic chmod Ar mode file-name
206 Change the permission modes of the file
214 session with the remote server, and
215 return to the command interpreter.
216 Any defined macros are erased.
218 Toggle carriage return stripping during
219 ascii type file retrieval.
220 Records are denoted by a carriage return/linefeed sequence
221 during ascii type file transfer.
224 is on (the default), carriage returns are stripped from this
225 sequence to conform with the
227 single linefeed record
231 remote systems may contain single linefeeds;
232 when an ascii type transfer is made, these linefeeds may be
233 distinguished from a record delimiter only when
236 .It Ic delete Ar remote-file
239 on the remote machine.
240 .It Ic debug Op Ar debug-value
241 Toggle debugging mode.
244 is specified it is used to set the debugging level.
245 When debugging is on,
247 prints each command sent to the remote machine, preceded
252 .Op Ar remote-directory
255 Print a listing of the directory contents in the
257 .Ar remote-directory ,
258 and, optionally, placing the output in
260 If interactive prompting is on,
262 will prompt the user to verify that the last argument is indeed the
263 target local file for receiving
266 If no directory is specified, the current working
267 directory on the remote machine is used.
269 file is specified, or
273 output comes to the terminal.
277 .It Ic form Ar format
278 Set the file transfer
282 The default format is \*(Lqfile\*(Rq.
283 .It Ic get Ar remote-file Op Ar local-file
286 and store it on the local machine.
288 file name is not specified, it is given the same
289 name it has on the remote machine, subject to
290 alteration by the current
296 The current settings for
302 are used while transferring the file.
304 Toggle filename expansion for
309 If globbing is turned off with
311 the file name arguments
312 are taken literally and not expanded.
321 each remote file name is expanded
322 separately on the remote machine and the lists are not merged.
323 Expansion of a directory name is likely to be
324 different from expansion of the name of an ordinary file:
325 the exact result depends on the foreign operating system and ftp server,
326 and can be previewed by doing
327 .Ql mls remote-files \- .
328 As a security measure, remotely globbed files that starts with
332 will not be automatically received. If you have interactive prompting
333 turned off, these filenames will be ignored. Note:
337 are not meant to transfer
338 entire directory subtrees of files.
342 archive of the subtree (in binary mode).
344 Toggle hash-sign (``#'') printing for each data block
346 The size of a data block is 1024 bytes.
347 .It Ic help Op Ar command
348 Print an informative message about the meaning of
350 If no argument is given,
352 prints a list of the known commands.
353 .It Ic idle Op Ar seconds
354 Set the inactivity timer on the remote server to
359 is omitted, the current inactivity timer is printed.
360 .It Ic lcd Op Ar directory
361 Change the working directory on the local machine.
365 is specified, the user's home directory is used.
368 .Op Ar remote-directory
371 Print a listing of the contents of a
372 directory on the remote machine.
373 The listing includes any system-dependent information that the server
374 chooses to include; for example, most
377 output from the command
383 is left unspecified, the current working directory is used.
384 If interactive prompting is on,
386 will prompt the user to verify that the last argument is indeed the
387 target local file for receiving
390 If no local file is specified, or if
394 the output is sent to the terminal.
395 .It Ic macdef Ar macro-name
397 Subsequent lines are stored as the macro
399 a null line (consecutive newline characters
401 carriage returns from the terminal) terminates macro input mode.
402 There is a limit of 16 macros and 4096 total characters in all
404 Macros remain defined until a
407 The macro processor interprets `$' and `\e' as special characters.
408 A `$' followed by a number (or numbers) is replaced by the
409 corresponding argument on the macro invocation command line.
410 A `$' followed by an `i' signals that macro processor that the
411 executing macro is to be looped.
412 On the first pass `$i' is
413 replaced by the first argument on the macro invocation command line,
414 on the second pass it is replaced by the second argument, and so on.
415 A `\e' followed by any character is replaced by that character.
416 Use the `\e' to prevent special treatment of the `$'.
417 .It Ic mdelete Op Ar remote-files
420 on the remote machine.
421 .It Ic mdir Ar remote-files local-file
424 except multiple remote files may be specified.
425 If interactive prompting is on,
427 will prompt the user to verify that the last argument is indeed the
428 target local file for receiving
431 .It Ic mget Ar remote-files
434 on the remote machine
437 for each file name thus produced.
440 for details on the filename expansion.
441 Resulting file names will then be processed according to
447 Files are transferred into the local working directory,
448 which can be changed with
450 new local directories can be created with
451 .Ql "\&! mkdir directory" .
452 .It Ic mkdir Ar directory-name
453 Make a directory on the remote machine.
454 .It Ic mls Ar remote-files local-file
457 except multiple remote files may be specified,
461 If interactive prompting is on,
463 will prompt the user to verify that the last argument is indeed the
464 target local file for receiving
467 .It Ic mode Op Ar mode-name
468 Set the file transfer
472 The default mode is \*(Lqstream\*(Rq mode.
473 .It Ic modtime Ar file-name
474 Show the last modification time of the file on the remote machine.
475 .It Ic mput Ar local-files
476 Expand wild cards in the list of local files given as arguments
479 for each file in the resulting list.
482 for details of filename expansion.
483 Resulting file names will then be processed according to
488 .It Ic newer Ar file-name
489 Get the file only if the modification time of the remote file is more
490 recent that the file on the current system.
492 exist on the current system, the remote file is considered
494 Otherwise, this command is identical to
498 .Op Ar remote-directory
501 Print a list of the files in a
502 directory on the remote machine.
505 is left unspecified, the current working directory is used.
506 If interactive prompting is on,
508 will prompt the user to verify that the last argument is indeed the
509 target local file for receiving
512 If no local file is specified, or if
516 the output is sent to the terminal.
517 .It Ic nmap Op Ar inpattern outpattern
518 Set or unset the filename mapping mechanism.
519 If no arguments are specified, the filename mapping mechanism is unset.
520 If arguments are specified, remote filenames are mapped during
524 commands issued without a specified remote target filename.
525 If arguments are specified, local filenames are mapped during
529 commands issued without a specified local target filename.
530 This command is useful when connecting to a
533 with different file naming conventions or practices.
534 The mapping follows the pattern set by
539 is a template for incoming filenames (which may have already been
540 processed according to the
545 Variable templating is accomplished by including the
546 sequences `$1', `$2', ..., `$9' in
548 Use `\\' to prevent this special treatment of the `$' character.
549 All other characters are treated literally, and are used to determine the
555 $1.$2 and the remote file name "mydata.data", $1 would have the value
556 "mydata", and $2 would have the value "data".
559 determines the resulting mapped filename.
560 The sequences `$1', `$2', ...., `$9' are replaced by any value resulting
564 The sequence `$0' is replace by the original filename.
565 Additionally, the sequence
566 .Ql Op Ar seq1 , Ar seq2
571 is not a null string; otherwise it is replaced by
573 For example, the command
575 .Bd -literal -offset indent -compact
576 nmap $1.$2.$3 [$1,$2].[$2,file]
580 the output filename "myfile.data" for input filenames "myfile.data" and
581 "myfile.data.old", "myfile.file" for the input filename "myfile", and
582 "myfile.myfile" for the input filename ".myfile".
583 Spaces may be included in
585 as in the example: `nmap $1 sed "s/ *$//" \*[Gt] $1' .
586 Use the `\e' character to prevent special treatment
587 of the `$','[','[', and `,' characters.
588 .It Ic ntrans Op Ar inchars Op Ar outchars
589 Set or unset the filename character translation mechanism.
590 If no arguments are specified, the filename character
591 translation mechanism is unset.
592 If arguments are specified, characters in
593 remote filenames are translated during
597 commands issued without a specified remote target filename.
598 If arguments are specified, characters in
599 local filenames are translated during
603 commands issued without a specified local target filename.
604 This command is useful when connecting to a
607 with different file naming conventions or practices.
608 Characters in a filename matching a character in
610 are replaced with the corresponding character in
612 If the character's position in
614 is longer than the length of
616 the character is deleted from the file name.
617 .It Ic open Ar host Op Ar port
618 Establish a connection to the specified
622 An optional port number may be supplied,
625 will attempt to contact an
630 option is on (default),
632 will also attempt to automatically log the user in to
637 Toggle passive mode. If passive mode is turned on
638 (default is off), the ftp client will
641 command for all data connections instead of the usual
645 command requests that the remote server open a port for the data connection
646 and return the address of that port. The remote server listens on that
647 port and the client connects to it. When using the more traditional
649 command, the client listens on a port and sends that address to the remote
650 server, who connects back to it. Passive mode is useful when using
652 through a gateway router or host that controls the directionality of
654 (Note that though ftp servers are required to support the
656 command by RFC 1123, some do not.)
658 Toggle interactive prompting.
659 Interactive prompting
660 occurs during multiple file transfers to allow the
661 user to selectively retrieve or store files.
662 If prompting is turned off (default is on), any
666 will transfer all files, and any
668 will delete all files.
669 .It Ic proxy Ar ftp-command
670 Execute an ftp command on a secondary control connection.
671 This command allows simultaneous connection to two remote ftp
672 servers for transferring files between the two servers.
677 to establish the secondary control connection.
678 Enter the command "proxy ?" to see other ftp commands executable on the
679 secondary connection.
680 The following commands behave differently when prefaced by
683 will not define new macros during the auto-login process,
685 will not erase existing macro definitions,
689 transfer files from the host on the primary control connection
690 to the host on the secondary control connection, and
695 transfer files from the host on the secondary control connection
696 to the host on the primary control connection.
697 Third party file transfers depend upon support of the ftp protocol
699 command by the server on the secondary control connection.
700 .It Ic put Ar local-file Op Ar remote-file
701 Store a local file on the remote machine.
704 is left unspecified, the local file name is used
705 after processing according to any
710 in naming the remote file.
711 File transfer uses the
719 Print the name of the current working directory on the remote
724 .It Ic quote Ar arg1 arg2 ...
725 The arguments specified are sent, verbatim, to the remote
728 .It Ic recv Ar remote-file Op Ar local-file
730 .It Ic reget Ar remote-file Op Ar local-file
731 Reget acts like get, except that if
738 a partially transferred copy of
741 is continued from the apparent point of failure.
743 is useful when transferring very large files over networks that
744 are prone to dropping connections.
745 .It Ic remotehelp Op Ar command-name
746 Request help from the remote
751 is specified it is supplied to the server as well.
752 .It Ic remotestatus Op Ar file-name
753 With no arguments, show status of remote machine.
756 is specified, show status of
766 on the remote machine, to the file
770 This command re-synchronizes command/reply sequencing with the remote
772 Resynchronization may be necessary following a violation of the ftp protocol
773 by the remote server.
774 .It Ic restart Ar marker
775 Restart the immediately following
784 systems, marker is usually a byte
785 offset into the file.
786 .It Ic rmdir Ar directory-name
787 Delete a directory on the remote machine.
789 Toggle storing of files on the local system with unique filenames.
790 If a file already exists with a name equal to the target
795 command, a ".1" is appended to the name.
796 If the resulting name matches another existing file,
797 a ".2" is appended to the original name.
798 If this process continues up to ".99", an error
799 message is printed, and the transfer does not take place.
800 The generated unique filename will be reported.
803 will not affect local files generated from a shell command
805 The default value is off.
806 .It Ic send Ar local-file Op Ar remote-file
814 will attempt to use a
816 command when establishing
817 a connection for each data transfer.
820 commands can prevent delays
821 when performing multiple file transfers.
826 will use the default data port.
829 commands is disabled, no attempt will be made to use
831 commands for each data transfer.
835 implementations which do ignore
837 commands but, incorrectly, indicate they've been accepted.
838 .It Ic site Ar arg1 arg2 ...
839 The arguments specified are sent, verbatim, to the remote
844 .It Ic size Ar file-name
849 Show the current status of
851 .It Ic struct Op Ar struct-name
852 Set the file transfer
856 By default \*(Lqstream\*(Rq structure is used.
858 Toggle storing of files on remote machine under unique file names.
859 Remote ftp server must support ftp protocol
862 successful completion.
863 The remote server will report unique name.
864 Default value is off.
866 Show the type of operating system running on the remote machine.
868 Set the file transfer type to that needed to
873 Toggle packet tracing.
874 .It Ic type Op Ar type-name
875 Set the file transfer
879 If no type is specified, the current type
881 The default type is network
883 .It Ic umask Op Ar newmask
884 Set the default umask on the remote server to
888 is omitted, the current umask is printed.
890 .Ic user Ar user-name
894 Identify yourself to the remote
899 is not specified and the server requires it,
901 will prompt the user for it (after disabling local echo).
904 field is not specified, and the
907 requires it, the user will be prompted for it.
910 field is specified, an account command will
911 be relayed to the remote server after the login sequence
912 is completed if the remote server did not require it
916 is invoked with \*(Lqauto-login\*(Rq disabled, this
917 process is done automatically on initial connection to
923 In verbose mode, all responses from
926 server are displayed to the user.
928 if verbose is on, when a file transfer completes, statistics
929 regarding the efficiency of the transfer are reported.
932 .It Ic \&? Op Ar command
936 The following command can be used with ftpsec-aware servers.
945 Set the data protection level to the requested level.
948 The following command can be used with ftp servers that has
949 implemented the KAUTH site command.
951 .It Ic kauth Op Ar principal
952 Obtain remote tickets.
955 Command arguments which have embedded spaces may be quoted with
957 .Sh ABORTING A FILE TRANSFER
958 To abort a file transfer, use the terminal interrupt key
960 Sending transfers will be immediately halted.
961 Receiving transfers will be halted by sending a ftp protocol
963 command to the remote server, and discarding any further data received.
964 The speed at which this is accomplished depends upon the remote
968 If the remote server does not support the
972 prompt will not appear until the remote server has completed
973 sending the requested file.
975 The terminal interrupt key sequence will be ignored when
977 has completed any local processing and is awaiting a reply
978 from the remote server.
979 A long delay in this mode may result from the ABOR processing described
980 above, or from unexpected behavior by the remote server, including
981 violations of the ftp protocol.
982 If the delay results from unexpected remote server behavior, the local
984 program must be killed by hand.
985 .Sh FILE NAMING CONVENTIONS
986 Files specified as arguments to
988 commands are processed according to the following rules.
997 (for writing) is used.
999 If the first character of the file name is
1002 remainder of the argument is interpreted as a shell command.
1004 then forks a shell, using
1006 with the argument supplied, and reads (writes) from the stdout
1008 If the shell command includes spaces, the argument
1009 must be quoted; e.g.
1010 \*(Lq" ls -lt"\*(Rq.
1012 useful example of this mechanism is: \*(Lqdir more\*(Rq.
1014 Failing the above checks, if ``globbing'' is enabled,
1015 local file names are expanded
1016 according to the rules used in the
1023 command expects a single local file (.e.g.
1025 only the first filename generated by the "globbing" operation is used.
1031 commands with unspecified local file names, the local filename is
1032 the remote filename, which may be altered by a
1038 The resulting filename may then be altered if
1046 commands with unspecified remote file names, the remote filename is
1047 the local filename, which may be altered by a
1052 The resulting filename may then be altered by the remote server if
1056 .Sh FILE TRANSFER PARAMETERS
1057 The FTP specification specifies many parameters which may
1058 affect a file transfer.
1061 may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
1062 \*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for
1068 supports the ascii and image types of file transfer,
1069 plus local byte size 8 for
1074 supports only the default values for the remaining
1075 file transfer parameters:
1083 file contains login and initialization information
1084 used by the auto-login process.
1085 It resides in the user's home directory.
1086 The following tokens are recognized; they may be separated by spaces,
1088 .Bl -tag -width password
1089 .It Ic machine Ar name
1090 Identify a remote machine
1092 The auto-login process searches the
1096 token that matches the remote machine specified on the
1098 command line or as an
1101 Once a match is made, the subsequent
1103 tokens are processed,
1104 stopping when the end of file is reached or another
1108 token is encountered.
1116 There can be only one
1118 token, and it must be after all
1121 This is normally used as:
1123 .Dl default login anonymous password user@site
1125 thereby giving the user
1127 anonymous ftp login to
1128 machines not specified in
1130 This can be overridden
1133 flag to disable auto-login.
1134 .It Ic login Ar name
1135 Identify a user on the remote machine.
1136 If this token is present, the auto-login process will initiate
1137 a login using the specified
1139 .It Ic password Ar string
1141 If this token is present, the auto-login process will supply the
1142 specified string if the remote server requires a password as part
1143 of the login process.
1144 Note that if this token is present in the
1146 file for any user other
1150 will abort the auto-login process if the
1153 anyone besides the user.
1154 .It Ic account Ar string
1155 Supply an additional account password.
1156 If this token is present, the auto-login process will supply the
1157 specified string if the remote server requires an additional
1158 account password, or the auto-login process will initiate an
1160 command if it does not.
1161 .It Ic macdef Ar name
1163 This token functions like the
1167 A macro is defined with the specified name; its contents begin with the
1170 line and continue until a null line (consecutive new-line
1171 characters) is encountered.
1174 is defined, it is automatically executed as the last step in the
1179 uses the following environment variables.
1182 For default location of a
1184 file, if one exists.
1199 Correct execution of many commands depends upon proper behavior
1200 by the remote server.
1202 An error in the treatment of carriage returns
1205 ascii-mode transfer code
1207 This correction may result in incorrect transfers of binary files
1210 servers using the ascii type.
1211 Avoid this problem by using the binary image type.