1FTP(1)                    BSD General Commands Manual                   FTP(1)
2

NAME

4     ftp — Internet file transfer program
5

SYNOPSIS

7     ftp [-pinegvd] [host]
8     pftp [-inegvd] [host]
9

DESCRIPTION

11     Ftp is the user interface to the Internet standard File Transfer Proto‐
12     col.  The program allows a user to transfer files to and from a remote
13     network site.
14
15     Options may be specified at the command line, or to the command inter‐
16     preter.
17
18     -p    Use passive mode for data transfers. Allows use of ftp in environ‐
19           ments where a firewall prevents connections from the outside world
20           back to the client machine. Requires that the ftp server support
21           the PASV command. This is the default now for all clients (ftp and
22           pftp) due to security concerns using the PORT transfer mode.  The
23           flag is kept for compatibility only and has no effect anymore.
24
25     -i    Turns off interactive prompting during multiple file transfers.
26
27     -n    Restrains ftp from attempting “auto-login” upon initial connection.
28           If auto-login is enabled, ftp will check the .netrc (see netrc(5))
29           file in the user's home directory for an entry describing an
30           account on the remote machine.  If no entry exists, ftp will prompt
31           for the remote machine login name (default is the user identity on
32           the local machine), and, if necessary, prompt for a password and an
33           account with which to login.
34
35     -e    Disables command editing and history support, if it was compiled
36           into the ftp executable. Otherwise, does nothing.
37
38     -g    Disables file name globbing.
39
40     -m    The default requires that ftp explicitly binds to the same inter‐
41           face for the data channel as the control channel in passive mode.
42           Useful on multi-homed clients. This option disables this behavior.
43
44     -v    Verbose option forces ftp to show all responses from the remote
45           server, as well as report on data transfer statistics.
46
47     -d    Enables debugging.
48
49     The client host with which ftp is to communicate may be specified on the
50     command line.  If this is done, ftp will immediately attempt to establish
51     a connection to an FTP server on that host; otherwise, ftp will enter its
52     command interpreter and await instructions from the user.  When ftp is
53     awaiting commands from the user the prompt ‘ftp>’ is provided to the
54     user.  The following commands are recognized by ftp:
55
56     ! [command [args]]
57                 Invoke an interactive shell on the local machine.  If there
58                 are arguments, the first is taken to be a command to execute
59                 directly, with the rest of the arguments as its arguments.
60
61     $ macro-name [args]
62                 Execute the macro macro-name that was defined with the macdef
63                 command.  Arguments are passed to the macro unglobbed.
64
65     account [passwd]
66                 Supply a supplemental password required by a remote system
67                 for access to resources once a login has been successfully
68                 completed.  If no argument is included, the user will be
69                 prompted for an account password in a non-echoing input mode.
70
71     append local-file [remote-file]
72                 Append a local file to a file on the remote machine.  If
73                 remote-file is left unspecified, the local file name is used
74                 in naming the remote file after being altered by any ntrans
75                 or nmap setting.  File transfer uses the current settings for
76                 type, format, mode, and structure.
77
78     ascii       Set the file transfer type to network ASCII.  This is the
79                 default type.
80
81     bell        Arrange that a bell be sounded after each file transfer com‐
82                 mand is completed.
83
84     binary      Set the file transfer type to support binary image transfer.
85
86     bye         Terminate the FTP session with the remote server and exit
87                 ftp.  An end of file will also terminate the session and
88                 exit.
89
90     case        Toggle remote computer file name case mapping during mget
91                 commands.  When case is on (default is off), remote computer
92                 file names with all letters in upper case are written in the
93                 local directory with the letters mapped to lower case.
94
95     cd remote-directory
96                 Change the working directory on the remote machine to
97                 remote-directory.
98
99     cdup        Change the remote machine working directory to the parent of
100                 the current remote machine working directory.
101
102     chmod mode file-name
103                 Change the permission modes of the file file-name on the
104                 remote sytem to mode.
105
106     close       Terminate the FTP session with the remote server, and return
107                 to the command interpreter.  Any defined macros are erased.
108
109     cr          Toggle carriage return stripping during ascii type file
110                 retrieval.  Records are denoted by a carriage return/linefeed
111                 sequence during ascii type file transfer.  When cr is on (the
112                 default), carriage returns are stripped from this sequence to
113                 conform with the UNIX single linefeed record delimiter.
114                 Records on non-UNIX remote systems may contain single line‐
115                 feeds; when an ascii type transfer is made, these linefeeds
116                 may be distinguished from a record delimiter only when cr is
117                 off.
118
119     delete remote-file
120                 Delete the file remote-file on the remote machine.
121
122     debug [debug-value]
123                 Toggle debugging mode.  If an optional debug-value is speci‐
124                 fied it is used to set the debugging level.  When debugging
125                 is on, ftp prints each command sent to the remote machine,
126                 preceded by the string ‘-->’
127
128     dir [remote-directory] [local-file]
129                 Print a listing of the directory contents in the directory,
130                 remote-directory, and, optionally, placing the output in
131                 local-file.  If interactive prompting is on, ftp will prompt
132                 the user to verify that the last argument is indeed the tar‐
133                 get local file for receiving dir output.  If no directory is
134                 specified, the current working directory on the remote
135                 machine is used.  If no local file is specified, or
136                 local-file is -, output comes to the terminal.
137
138     disconnect  A synonym for close.
139
140     form format
141                 Set the file transfer form to format.  The default format is
142                 “file”.
143
144     get remote-file [local-file]
145                 Retrieve the remote-file and store it on the local machine.
146                 If the local file name is not specified, it is given the same
147                 name it has on the remote machine, subject to alteration by
148                 the current case, ntrans, and nmap settings.  The current
149                 settings for type, form, mode, and structure are used while
150                 transferring the file.
151
152     glob        Toggle filename expansion for mdelete, mget and mput.  If
153                 globbing is turned off with glob, the file name arguments are
154                 taken literally and not expanded.  Globbing for mput is done
155                 as in csh(1).  For mdelete and mget, each remote file name is
156                 expanded separately on the remote machine and the lists are
157                 not merged.  Expansion of a directory name is likely to be
158                 different from expansion of the name of an ordinary file: the
159                 exact result depends on the foreign operating system and ftp
160                 server, and can be previewed by doing ‘mls remote-files -’
161                 Note: mget and mput are not meant to transfer entire direc‐
162                 tory subtrees of files.  That can be done by transferring a
163                 tar(1) archive of the subtree (in binary mode).
164
165     hash        Toggle hash-sign (``#'') printing for each data block trans‐
166                 ferred.  The size of a data block is 1024 bytes.
167
168     help [command]
169                 Print an informative message about the meaning of command.
170                 If no argument is given, ftp prints a list of the known com‐
171                 mands.
172
173     idle [seconds]
174                 Set the inactivity timer on the remote server to seconds sec‐
175                 onds.  If seconds is ommitted, the current inactivity timer
176                 is printed.
177
178     lcd [directory]
179                 Change the working directory on the local machine.  If no
180                 directory is specified, the user's home directory is used.
181
182     ls [remote-directory] [local-file]
183                 Print a listing of the contents of a directory on the remote
184                 machine.  The listing includes any system-dependent informa‐
185                 tion that the server chooses to include; for example, most
186                 UNIX systems will produce output from the command ‘ls -l’.
187                 (See also nlist.)  If remote-directory is left unspecified,
188                 the current working directory is used.  If interactive
189                 prompting is on, ftp will prompt the user to verify that the
190                 last argument is indeed the target local file for receiving
191                 ls output.  If no local file is specified, or if local-file
192                 is ‘-’, the output is sent to the terminal.
193
194     macdef macro-name
195                 Define a macro.  Subsequent lines are stored as the macro
196                 macro-name; a null line (consecutive newline characters in a
197                 file or carriage returns from the terminal) terminates macro
198                 input mode.  There is a limit of 16 macros and 4096 total
199                 characters in all defined macros.  Macros remain defined
200                 until a close command is executed.  The macro processor
201                 interprets `$' and `\' as special characters.  A `$' followed
202                 by a number (or numbers) is replaced by the corresponding
203                 argument on the macro invocation command line.  A `$' fol‐
204                 lowed by an `i' signals that macro processor that the execut‐
205                 ing macro is to be looped.  On the first pass `$i' is
206                 replaced by the first argument on the macro invocation com‐
207                 mand line, on the second pass it is replaced by the second
208                 argument, and so on.  A `\' followed by any character is
209                 replaced by that character.  Use the `\' to prevent special
210                 treatment of the `$'.
211
212     mdelete [remote-files]
213                 Delete the remote-files on the remote machine.
214
215     mdir remote-files local-file
216                 Like dir, except multiple remote files may be specified.  If
217                 interactive prompting is on, ftp will prompt the user to ver‐
218                 ify that the last argument is indeed the target local file
219                 for receiving mdir output.
220
221     mget remote-files
222                 Expand the remote-files on the remote machine and do a get
223                 for each file name thus produced.  See glob for details on
224                 the filename expansion.  Resulting file names will then be
225                 processed according to case, ntrans, and nmap settings.
226                 Files are transferred into the local working directory, which
227                 can be changed with ‘lcd directory’; new local directories
228                 can be created with ‘! mkdir directory’.
229
230     mkdir directory-name
231                 Make a directory on the remote machine.
232
233     mls remote-files local-file
234                 Like nlist, except multiple remote files may be specified,
235                 and the local-file must be specified.  If interactive prompt‐
236                 ing is on, ftp will prompt the user to verify that the last
237                 argument is indeed the target local file for receiving mls
238                 output.
239
240     mode [mode-name]
241                 Set the file transfer mode to mode-name.  The default mode is
242                 “stream” mode.
243
244     modtime file-name
245                 Show the last modification time of the file on the remote
246                 machine.
247
248     mput local-files
249                 Expand wild cards in the list of local files given as argu‐
250                 ments and do a put for each file in the resulting list.  See
251                 glob for details of filename expansion.  Resulting file names
252                 will then be processed according to ntrans and nmap settings.
253
254     newer file-name [local-file]
255                 Get the file only if the modification time of the remote file
256                 is more recent that the file on the current system.  If the
257                 file does not exist on the current system, the remote file is
258                 considered newer.  Otherwise, this command is identical to
259                 get.
260
261     nlist [remote-directory] [local-file]
262                 Print a  list of the files in a directory on the remote
263                 machine.  If remote-directory is left unspecified, the cur‐
264                 rent working directory is used.  If interactive prompting is
265                 on, ftp will prompt the user to verify that the last argument
266                 is indeed the target local file for receiving nlist output.
267                 If no local file is specified, or if local-file is -, the
268                 output is sent to the terminal.
269
270     nmap [inpattern outpattern]
271                 Set or unset the filename mapping mechanism.  If no arguments
272                 are specified, the filename mapping mechanism is unset.  If
273                 arguments are specified, remote filenames are mapped during
274                 mput commands and put commands issued without a specified
275                 remote target filename.  If arguments are specified, local
276                 filenames are mapped during mget commands and get commands
277                 issued without a specified local target filename.  This com‐
278                 mand is useful when connecting to a non-UNIX remote computer
279                 with different file naming conventions or practices.  The
280                 mapping follows the pattern set by inpattern and outpattern.
281                 [Inpattern] is a template for incoming filenames (which may
282                 have already been processed according to the ntrans and case
283                 settings).  Variable templating is accomplished by including
284                 the sequences `$1', `$2', ..., `$9' in inpattern.  Use `\' to
285                 prevent this special treatment of the `$' character.  All
286                 other characters are treated literally, and are used to
287                 determine the nmap [inpattern] variable values.  For example,
288                 given inpattern $1.$2 and the remote file name "mydata.data",
289                 $1 would have the value "mydata", and $2 would have the value
290                 "data".  The outpattern determines the resulting mapped file‐
291                 name.  The sequences `$1', `$2', ...., `$9' are replaced by
292                 any value resulting from the inpattern template.  The
293                 sequence `$0' is replace by the original filename.  Addition‐
294                 ally, the sequence ‘[seq1, seq2]’ is replaced by [seq1] if
295                 seq1 is not a null string; otherwise it is replaced by seq2.
296                 For example, the command
297
298                       nmap $1.$2.$3 [$1,$2].[$2,file]
299
300                 would yield the output filename "myfile.data" for input file‐
301                 names "myfile.data" and "myfile.data.old", "myfile.file" for
302                 the input filename "myfile", and "myfile.myfile" for the
303                 input filename ".myfile".  Spaces may be included in
304                 outpattern, as in the example: `nmap $1 sed "s/  *$//" > $1'
305                 .  Use the `\' character to prevent special treatment of the
306                 `$','[','[', and `,' characters.
307
308     ntrans [inchars [outchars]]
309                 Set or unset the filename character translation mechanism.
310                 If no arguments are specified, the filename character trans‐
311                 lation mechanism is unset.  If arguments are specified, char‐
312                 acters in remote filenames are translated during mput com‐
313                 mands and put commands issued without a specified remote tar‐
314                 get filename.  If arguments are specified, characters in
315                 local filenames are translated during mget commands and get
316                 commands issued without a specified local target filename.
317                 This command is useful when connecting to a non-UNIX remote
318                 computer with different file naming conventions or practices.
319                 Characters in a filename matching a character in inchars are
320                 replaced with the corresponding character in outchars.  If
321                 the character's position in inchars is longer than the length
322                 of outchars, the character is deleted from the file name.
323
324     open host [port]
325                 Establish a connection to the specified host FTP server.  An
326                 optional port number may be supplied, in which case, ftp will
327                 attempt to contact an FTP server at that port.  If the
328                 auto-login option is on (default), ftp will also attempt to
329                 automatically log the user in to the FTP server (see below).
330
331     prompt      Toggle interactive prompting.  Interactive prompting occurs
332                 during multiple file transfers to allow the user to selec‐
333                 tively retrieve or store files.  If prompting is turned off
334                 (default is on), any mget or mput will transfer all files,
335                 and any mdelete will delete all files.
336
337     proxy ftp-command
338                 Execute an ftp command on a secondary control connection.
339                 This command allows simultaneous connection to two remote ftp
340                 servers for transferring files between the two servers.  The
341                 first proxy command should be an open, to establish the sec‐
342                 ondary control connection.  Enter the command "proxy ?" to
343                 see other ftp commands executable on the secondary connec‐
344                 tion.  The following commands behave differently when pref‐
345                 aced by proxy: open will not define new macros during the
346                 auto-login process, close will not erase existing macro defi‐
347                 nitions, get and mget transfer files from the host on the
348                 primary control connection to the host on the secondary con‐
349                 trol connection, and put, mput, and append transfer files
350                 from the host on the secondary control connection to the host
351                 on the primary control connection.  Third party file trans‐
352                 fers depend upon support of the ftp protocol PASV command by
353                 the server on the secondary control connection.
354
355     put local-file [remote-file]
356                 Store a local file on the remote machine.  If remote-file is
357                 left unspecified, the local file name is used after process‐
358                 ing according to any ntrans or nmap settings in naming the
359                 remote file.  File transfer uses the current settings for
360                 type, format, mode, and structure.
361
362     pwd         Print the name of the current working directory on the remote
363                 machine.
364
365     quit        A synonym for bye.
366
367     quote arg1 arg2 ...
368                 The arguments specified are sent, verbatim, to the remote FTP
369                 server.
370
371     recv remote-file [local-file]
372                 A synonym for get.
373
374     reget remote-file [local-file]
375                 Reget acts like get, except that if local-file exists and is
376                 smaller than remote-file, local-file is presumed to be a par‐
377                 tially transferred copy of remote-file and the transfer is
378                 continued from the apparent point of failure.  This command
379                 is useful when transferring very large files over networks
380                 that are prone to dropping connections.
381
382     remotehelp [command-name]
383                 Request help from the remote FTP server.  If a command-name
384                 is specified it is supplied to the server as well.
385
386     remotestatus [file-name]
387                 With no arguments, show status of remote machine.  If
388                 file-name is specified, show status of file-name on remote
389                 machine.
390
391     rename [from] [to]
392                 Rename the file from on the remote machine, to the file to.
393
394     reset       Clear reply queue.  This command re-synchronizes com‐
395                 mand/reply sequencing with the remote ftp server.  Resynchro‐
396                 nization may be necessary following a violation of the ftp
397                 protocol by the remote server.
398
399     restart marker
400                 Restart the immediately following get or put at the indicated
401                 marker.  On UNIX systems, marker is usually a byte offset
402                 into the file.
403
404     rmdir directory-name
405                 Delete a directory on the remote machine.
406
407     runique     Toggle storing of files on the local system with unique file‐
408                 names.  If a file already exists with a name equal to the
409                 target local filename for a get or mget command, a ".1" is
410                 appended to the name.  If the resulting name matches another
411                 existing file, a ".2" is appended to the original name.  If
412                 this process continues up to ".99", an error message is
413                 printed, and the transfer does not take place.  The generated
414                 unique filename will be reported.  Note that runique will not
415                 affect local files generated from a shell command (see
416                 below).  The default value is off.
417
418     send local-file [remote-file]
419                 A synonym for put.
420
421     sendport    Toggle the use of PORT commands.  By default, ftp will
422                 attempt to use a PORT command when establishing a connection
423                 for each data transfer.  The use of PORT commands can prevent
424                 delays when performing multiple file transfers.  If the PORT
425                 command fails, ftp will use the default data port.  When the
426                 use of PORT commands is disabled, no attempt will be made to
427                 use PORT commands for each data transfer.  This is useful for
428                 certain FTP implementations which do ignore PORT commands
429                 but, incorrectly, indicate they've been accepted.
430
431     site arg1 arg2 ...
432                 The arguments specified are sent, verbatim, to the remote FTP
433                 server as a SITE command.
434
435     size file-name
436                 Return size of file-name on remote machine.
437
438     status      Show the current status of ftp.
439
440     struct [struct-name]
441                 Set the file transfer structure to struct-name.  By default
442                 “stream” structure is used.
443
444     sunique     Toggle storing of files on remote machine under unique file
445                 names.  Remote ftp server must support ftp protocol STOU com‐
446                 mand for successful completion.  The remote server will
447                 report unique name.  Default value is off.
448
449     system      Show the type of operating system running on the remote
450                 machine.
451
452     tenex       Set the file transfer type to that needed to talk to TENEX
453                 machines.
454
455     trace       Toggle packet tracing.
456
457     type [type-name]
458                 Set the file transfer type to type-name.  If no type is spec‐
459                 ified, the current type is printed.  The default type is net‐
460                 work ASCII.
461
462     umask [newmask]
463                 Set the default umask on the remote server to newmask.  If
464                 newmask is ommitted, the current umask is printed.
465
466     user user-name [password] [account]
467                 Identify yourself to the remote FTP server.  If the password
468                 is not specified and the server requires it, ftp will prompt
469                 the user for it (after disabling local echo).  If an account
470                 field is not specified, and the FTP server requires it, the
471                 user will be prompted for it.  If an account field is speci‐
472                 fied, an account command will be relayed to the remote server
473                 after the login sequence is completed if the remote server
474                 did not require it for logging in.  Unless ftp is invoked
475                 with “auto-login” disabled, this process is done automati‐
476                 cally on initial connection to the FTP server.
477
478     verbose     Toggle verbose mode.  In verbose mode, all responses from the
479                 FTP server are displayed to the user.  In addition, if ver‐
480                 bose is on, when a file transfer completes, statistics
481                 regarding the efficiency of the transfer are reported.  By
482                 default, verbose is on.
483
484     ? [command]
485                 A synonym for help.
486
487     Command arguments which have embedded spaces may be quoted with quote `"'
488     marks.
489

ABORTING A FILE TRANSFER

491     To abort a file transfer, use the terminal interrupt key (usually Ctrl-
492     C).  Sending transfers will be immediately halted.  Receiving transfers
493     will be halted by sending a ftp protocol ABOR command to the remote
494     server, and discarding any further data received.  The speed at which
495     this is accomplished depends upon the remote server's support for ABOR
496     processing.  If the remote server does not support the ABOR command, an
497     ‘ftp>’ prompt will not appear until the remote server has completed send‐
498     ing the requested file.
499
500     The terminal interrupt key sequence will be ignored when ftp has com‐
501     pleted any local processing and is awaiting a reply from the remote
502     server.  A long delay in this mode may result from the ABOR processing
503     described above, or from unexpected behavior by the remote server,
504     including violations of the ftp protocol.  If the delay results from
505     unexpected remote server behavior, the local ftp program must be killed
506     by hand.
507

FILE NAMING CONVENTIONS

509     Files specified as arguments to ftp commands are processed according to
510     the following rules.
511
512     1.   If the file name ‘-’ is specified, the stdin (for reading) or stdout
513          (for writing) is used.
514
515     2.   If the first character of the file name is ‘|’, the remainder of the
516          argument is interpreted as a shell command.  Ftp then forks a shell,
517          using popen(3) with the argument supplied, and reads (writes) from
518          the stdout (stdin).  If the shell command includes spaces, the argu‐
519          ment must be quoted; e.g.  “" ls -lt"”.  A particularly useful exam‐
520          ple of this mechanism is: “dir more”.
521
522     3.   Failing the above checks, if ``globbing'' is enabled, local file
523          names are expanded according to the rules used in the csh(1); c.f.
524          the glob command.  If the ftp command expects a single local file
525          (.e.g.  put), only the first filename generated by the "globbing"
526          operation is used.
527
528     4.   For mget commands and get commands with unspecified local file
529          names, the local filename is the remote filename, which may be
530          altered by a case, ntrans, or nmap setting.  The resulting filename
531          may then be altered if runique is on.
532
533     5.   For mput commands and put commands with unspecified remote file
534          names, the remote filename is the local filename, which may be
535          altered by a ntrans or nmap setting.  The resulting filename may
536          then be altered by the remote server if sunique is on.
537

FILE TRANSFER PARAMETERS

539     The FTP specification specifies many parameters which may affect a file
540     transfer.  The type may be one of “ascii”, “image” (binary), “ebcdic”,
541     and “local byte size” (for PDP-10's and PDP-20's mostly).  Ftp supports
542     the ascii and image types of file transfer, plus local byte size 8 for
543     tenex mode transfers.
544
545     Ftp supports only the default values for the remaining file transfer
546     parameters: mode, form, and struct.
547

ENVIRONMENT

549     Ftp utilizes the following environment variables.
550
551     HOME        For default location of a .netrc file, if one exists.
552
553     SHELL       For default shell.
554

SEE ALSO

556     ftpd(8), RFC 959
557

HISTORY

559     The ftp command appeared in 4.2BSD.
560

BUGS

562     Correct execution of many commands depends upon proper behavior by the
563     remote server.
564
565     An error in the treatment of carriage returns in the 4.2BSD ascii-mode
566     transfer code has been corrected.  This correction may result in incor‐
567     rect transfers of binary files to and from 4.2BSD servers using the ascii
568     type.  Avoid this problem by using the binary image type.
569
570Linux NetKit (0.17)             August 15, 1999            Linux NetKit (0.17)
Impressum