fix perror messages for tos
[unix-history] / usr / src / usr.bin / ftp / ftp.1
CommitLineData
b5dc1377 1.\" Copyright (c) 1985, 1989, 1990 The Regents of the University of California.
cb8ade2f 2.\" All rights reserved.
9e7fc5bf 3.\"
b5dc1377 4.\" %sccs.include.redist.man%
9e7fc5bf 5.\"
b5dc1377 6.\" @(#)ftp.1 6.14 (Berkeley) %G%
cb8ade2f 7.\"
b5dc1377
CL
8.Dd
9.Dt FTP 1
10.Os BSD 4.2
11.Sh NAME
12.Nm ftp
13.Nd ARPANET file transfer program
14.Sh SYNOPSIS
15.Nm ftp
16.Op Fl v
17.Op Fl d
18.Op Fl i
19.Op Fl n
20.Op Fl g
21.Op Ar host
22.Sh DESCRIPTION
23.Nm Ftp
9e7fc5bf 24is the user interface to the ARPANET standard File Transfer Protocol.
a154ee89
GM
25The program allows a user to transfer files to and from a
26remote network site.
b5dc1377
CL
27.Pp
28Options may be specified at the command line, or to the
29command interpreter.
30.Tp Fl v
31Verbose option forces
32.Nm ftp
33to show all responses from the remote server, as well
34as report on data transfer statistics.
35.Tp Fl n
36Restrains
37.Nm ftp
38from attempting \*(Lqauto-login\*(Rq upon initial connection.
39If auto-login is enabled,
40.Nm ftp
41will check the
42.Pa .netrc
43(see below) file in the user's home directory for an entry describing
44an account on the remote machine. If no entry exists,
45.Nm ftp
46will prompt for the remote machine login name (default is the user
47identity on the local machine), and, if necessary, prompt for a password
48and an account with which to login.
49.Tp Fl i
50Turns off interactive prompting during
51multiple file transfers.
52.Tp Fl d
53Enables debugging.
54.Tp Fl g
55Disables file name globbing.
56.Tp
57.Pp
58The client host with which
59.Nm ftp
9e7fc5bf
KM
60is to communicate may be specified on the command line.
61If this is done,
b5dc1377 62.Nm ftp
a154ee89 63will immediately attempt to establish a connection to an FTP
b5dc1377
CL
64server on that host; otherwise,
65.Nm ftp
a154ee89 66will enter its command interpreter and await instructions
b5dc1377
CL
67from the user. When
68.Nm ftp
69is awaiting commands from the user the prompt \*(Lqftp>\*(Rq
adbdb3c0 70is provided to the user. The following commands are recognized
9e7fc5bf 71by
b5dc1377
CL
72.Nm ftp :
73.Tw Fl
74.Tp Cx Ic \&!
75.Cx \&\ \&
76.Op Ar command Op Ar args
77.Cx
a154ee89
GM
78Invoke an interactive shell on the local machine.
79If there are arguments, the first is taken to be a command to execute
80directly, with the rest of the arguments as its arguments.
b5dc1377
CL
81.Tp Cx Ic \&$
82.Cx \&\ \&
83.Ar macro-name
84.Op Ar args
85.Cx
86Execute the macro
87.Ar macro-name
88that was defined with the
89.Ic macdef
90command.
a154ee89 91Arguments are passed to the macro unglobbed.
b5dc1377
CL
92.Tp Cx Ic account
93.Cx \&\ \&
94.Op Ar passwd
95.Cx
a154ee89
GM
96Supply a supplemental password required by a remote system for access
97to resources once a login has been successfully completed.
98If no argument is included, the user will be prompted for an account
99password in a non-echoing input mode.
b5dc1377
CL
100.Tp Cx Ic append
101.Cx \&\ \&
102.Ar local-file
103.Cx \&\ \&
104.Op Ar remote-file
105.Cx
9e7fc5bf 106Append a local file to a file on the remote machine. If
b5dc1377 107.Ar remote-file
9e7fc5bf 108is left unspecified, the local file name is used in naming the
a154ee89 109remote file after being altered by any
b5dc1377 110.Ic ntrans
a154ee89 111or
b5dc1377 112.Ic nmap
a154ee89
GM
113setting.
114File transfer uses the current settings for
b5dc1377
CL
115.Ic type ,
116.Ic format ,
117.Ic mode ,
a154ee89 118and
b5dc1377
CL
119.Ic structure .
120.Tp Ic ascii
121Set the file transfer
122.Ic type
a154ee89 123to network ASCII. This is the default type.
b5dc1377 124.Tp Ic bell
9e7fc5bf
KM
125Arrange that a bell be sounded after each file transfer
126command is completed.
b5dc1377 127.Tp Ic binary
a154ee89 128Set the file transfer
b5dc1377 129.Ic type
a154ee89 130to support binary image transfer.
b5dc1377 131.Tp Ic bye
9e7fc5bf
KM
132Terminate the FTP session with the remote server
133and exit
b5dc1377 134.Nm ftp .
3c604e97 135An end of file will also terminate the session and exit.
b5dc1377 136.Tp Ic case
a154ee89 137Toggle remote computer file name case mapping during
b5dc1377 138.Ic mget
a154ee89
GM
139commands.
140When
b5dc1377 141.Ic case
a154ee89
GM
142is on (default is off), remote computer file names with all letters in
143upper case are written in the local directory with the letters mapped
144to lower case.
b5dc1377
CL
145.Tp Cx Ic cd
146.Cx \&\ \&
147.Ar remote-directory
148.Cx
9e7fc5bf 149Change the working directory on the remote machine
b5dc1377
CL
150to
151.Ar remote-directory .
152.Tp Ic cdup
a154ee89
GM
153Change the remote machine working directory to the parent of the
154current remote machine working directory.
b5dc1377
CL
155.Tp Cx Ic chmod
156.Cx \&\ \&
157.Ar mode file-name
158.Cx
159Change the permission modes the file
160.Ar file-name
161on the remote
162sytem to
163.Ic mode .
164.Tp Ic close
9e7fc5bf
KM
165Terminate the FTP session with the remote server, and
166return to the command interpreter.
a154ee89 167Any defined macros are erased.
b5dc1377 168.Tp Ic cr
a154ee89
GM
169Toggle carriage return stripping during
170ascii type file retrieval.
171Records are denoted by a carriage return/linefeed sequence
172during ascii type file transfer.
173When
b5dc1377 174.Ic cr
a154ee89
GM
175is on (the default), carriage returns are stripped from this
176sequence to conform with the UNIX single linefeed record
177delimiter.
178Records on non-UNIX remote systems may contain single linefeeds;
179when an ascii type transfer is made, these linefeeds may be
180distinguished from a record delimiter only when
b5dc1377 181.Ic cr
a154ee89 182is off.
b5dc1377
CL
183.Tp Cx Ic delete
184.Cx \&\ \&
185.Ar remote-file
186.Cx
9e7fc5bf 187Delete the file
b5dc1377 188.Ar remote-file
9e7fc5bf 189on the remote machine.
b5dc1377
CL
190.Tp Cx Ic debug
191.Cx \&\ \&
192.Op Ar debug-value
193.Cx
9e7fc5bf 194Toggle debugging mode. If an optional
b5dc1377 195.Ar debug-value
9e7fc5bf
KM
196is specified it is used to set the debugging level.
197When debugging is on,
b5dc1377 198.Nm ftp
9e7fc5bf 199prints each command sent to the remote machine, preceded
b5dc1377
CL
200by the string \*(Lq-->\*(Rq.
201.Tp Cx Ic dir
202.Cx \&\ \&
203.Op Ar remote-directory
204.Cx \&\ \&
205.Op Ar local-file
206.Cx
9e7fc5bf
KM
207Print a listing of the directory contents in the
208directory,
b5dc1377 209.Ar remote-directory ,
9e7fc5bf 210and, optionally, placing the output in
b5dc1377 211.Ar local-file .
cd8a871b 212If interactive prompting is on,
b5dc1377 213.Nm ftp
cd8a871b
KB
214will prompt the user to verify that the last argument is indeed the
215target local file for receiving
b5dc1377 216.Ic dir
cd8a871b 217output.
9e7fc5bf
KM
218If no directory is specified, the current working
219directory on the remote machine is used. If no local
b5dc1377
CL
220file is specified, or
221.Ar local-file
222is
223.Fl ,
1609770c 224output comes to the terminal.
b5dc1377 225.Tp Ic disconnect
a154ee89 226A synonym for
b5dc1377
CL
227.Ar close .
228.Tp Cx Ic form
229.Cx \&\ \&
230.Ar format
231.Cx
232Set the file transfer
233.Ic form
234to
235.Ar format .
236The default format is \*(Lqfile\*(Rq.
237.Tp Cx Ic get
238.Cx \&\ \&
239.Ar remote-file
240.Cx \&\ \&
241.Op Ar local-file
242.Cx
243Retrieve the
244.Ar remote-file
9e7fc5bf
KM
245and store it on the local machine. If the local
246file name is not specified, it is given the same
a154ee89
GM
247name it has on the remote machine, subject to
248alteration by the current
b5dc1377
CL
249.Ic case ,
250.Ic ntrans ,
a154ee89 251and
b5dc1377 252.Ic nmap
a154ee89 253settings.
b5dc1377
CL
254The current settings for
255.Ic type ,
256.Ic form ,
257.Ic mode ,
a154ee89 258and
b5dc1377 259.Ic structure
9e7fc5bf 260are used while transferring the file.
b5dc1377
CL
261.Tp Ic glob
262Toggle filename expansion for
263.Ic mdelete ,
264.Ic mget
265and
266.Ic mput .
267If globbing is turned off with
268.Ic glob ,
269the file name arguments
a154ee89 270are taken literally and not expanded.
b5dc1377
CL
271Globbing for
272.Ic mput
273is done as in
274.Xr csh 1 .
275For
276.Ic mdelete
277and
278.Ic mget ,
279each remote file name is expanded
a154ee89 280separately on the remote machine and the lists are not merged.
b5dc1377 281Expansion of a directory name is likely to be
1609770c 282different from expansion of the name of an ordinary file:
a154ee89 283the exact result depends on the foreign operating system and ftp server,
b5dc1377
CL
284and can be previewed by doing
285.Cx `
286.Cx Li mls remote-files \-
287.Cx \'.
288.Cx
289Note:
290.Ic mget
291and
292.Ic mput
293are not meant to transfer
a154ee89 294entire directory subtrees of files. That can be done by
b5dc1377
CL
295transferring a
296.Xr tar 1
297archive of the subtree (in binary mode).
298.Tp Ic hash
9e7fc5bf
KM
299Toggle hash-sign (``#'') printing for each data block
300transferred. The size of a data block is 1024 bytes.
b5dc1377
CL
301.Tp Cx Ic help
302.Cx \&\ \&
303.Op Ar command
304.Cx
9e7fc5bf 305Print an informative message about the meaning of
b5dc1377
CL
306.Ar command .
307If no argument is given,
308.Nm ftp
9e7fc5bf 309prints a list of the known commands.
b5dc1377
CL
310.Tp Cx Ic idle
311.Cx \&\ \&
312.Op Ar seconds
313.Cx
314Set the inactivity timer on the remote server to
315.Ar seconds
316seconds.
317If
318.Ar seconds
319is ommitted, the current inactivity timer is printed.
320.Tp Cx Ic lcd
321.Cx \&\ \&
322.Op Ar directory
323.Cx
9e7fc5bf 324Change the working directory on the local machine. If
b5dc1377
CL
325no
326.Ar directory
9e7fc5bf 327is specified, the user's home directory is used.
b5dc1377
CL
328.Tp Cx Ic ls
329.Cx \&\ \&
330.Op Ar remote-directory
331.Cx \&\ \&
332.Op Ar local-file
333.Cx
ff00793c 334Print a listing of the contents of a
cdc35b45
MK
335directory on the remote machine.
336The listing includes any system-dependent information that the server
337chooses to include; for example, most UNIX systems will produce
b5dc1377
CL
338output from the command \*(Lqls -l\*(Rq.
339(See also
340.Ic nlist .
341)
cdc35b45 342If
b5dc1377 343.Ar remote-directory
cd8a871b
KB
344is left unspecified, the current working directory is used.
345If interactive prompting is on,
b5dc1377 346.Nm ftp
cd8a871b
KB
347will prompt the user to verify that the last argument is indeed the
348target local file for receiving
b5dc1377 349.Ic ls
cd8a871b 350output.
b5dc1377
CL
351If no local file is specified, or if
352.Ar local-file
353is
354.Fl ,
1609770c 355the output is sent to the terminal.
b5dc1377
CL
356.Tp Cx Ic macdef
357.Cx \&\ \&
358.Ar macro-name
359.Cx
a154ee89
GM
360Define a macro.
361Subsequent lines are stored as the macro
b5dc1377
CL
362.Ar macro-name ;
363a null line (consecutive newline characters
a154ee89
GM
364in a file or
365carriage returns from the terminal) terminates macro input mode.
366There is a limit of 16 macros and 4096 total characters in all
367defined macros.
368Macros remain defined until a
b5dc1377 369.Ic close
a154ee89
GM
370command is executed.
371The macro processor interprets '$' and '\\' as special characters.
372A '$' followed by a number (or numbers) is replaced by the
373corresponding argument on the macro invocation command line.
374A '$' followed by an 'i' signals that macro processor that the
375executing macro is to be looped. On the first pass '$i' is
376replaced by the first argument on the macro invocation command line,
377on the second pass it is replaced by the second argument, and so on.
378A '\\' followed by any character is replaced by that character.
379Use the '\\' to prevent special treatment of the '$'.
b5dc1377
CL
380.Tp Cx Ic mdelete
381.Cx \&\ \&
382.Op Ar remote-files
383.Cx
384Delete the
385.Ar remote-files
386on the remote machine.
387.Tp Cx Ic mdir
388.Cx \&\ \&
389.Ar remote-files
390.Cx \&\ \&
391.Ar local-file
392.Cx
393Like
394.Ic dir ,
395except multiple remote files may be specified.
a154ee89 396If interactive prompting is on,
b5dc1377 397.Nm ftp
a154ee89
GM
398will prompt the user to verify that the last argument is indeed the
399target local file for receiving
b5dc1377 400.Ic mdir
a154ee89 401output.
b5dc1377
CL
402.Tp Cx Ic mget
403.Cx \&\ \&
404.Ar remote-files
405.Cx
406Expand the
407.Ar remote-files
408on the remote machine
409and do a
410.Ic get
411for each file name thus produced.
412See
413.Ic glob
414for details on the filename expansion.
a154ee89 415Resulting file names will then be processed according to
b5dc1377
CL
416.Ic case ,
417.Ic ntrans ,
a154ee89 418and
b5dc1377 419.Ic nmap
a154ee89 420settings.
1609770c 421Files are transferred into the local working directory,
b5dc1377
CL
422which can be changed with
423.Cx `
424.Cx Li lcd directory
425.Cx \';
426new local directories can be created with
427.Cx Li \&! mkdir directory
428.Cx \'.
429.Tp Cx Ic mkdir
430.Cx \&\ \&
431.Ar directory-name
432.Cx
9e7fc5bf 433Make a directory on the remote machine.
b5dc1377
CL
434.Tp Cx Ic mls
435.Cx \&\ \&
436.Ar remote-files
437.Cx \&\ \&
438.Ar local-file
439.Cx
440Like
441.Ic nlist ,
442except multiple remote files may be specified,
443and the
444.Ar local-file
445must be specified.
a154ee89 446If interactive prompting is on,
b5dc1377 447.Nm ftp
a154ee89
GM
448will prompt the user to verify that the last argument is indeed the
449target local file for receiving
b5dc1377 450.Ic mls
a154ee89 451output.
b5dc1377
CL
452.Tp Cx Ic mode
453.Cx \&\ \&
454.Op Ar mode-name
455.Cx
a154ee89 456Set the file transfer
b5dc1377 457.Ic mode
a154ee89 458to
b5dc1377
CL
459.Ar mode-name .
460The default mode is \*(Lqstream\*(Rq mode.
461.Tp Cx Ic modtime
462.Cx \&\ \&
463.Ar file-name
464.Cx
ff00793c 465Show the last modification time of the file on the remote machine.
b5dc1377
CL
466.Tp Cx Ic mput
467.Cx \&\ \&
468.Ar local-files
469.Cx
1609770c 470Expand wild cards in the list of local files given as arguments
b5dc1377
CL
471and do a
472.Ic put
473for each file in the resulting list.
474See
475.Ic glob
476for details of filename expansion.
a154ee89 477Resulting file names will then be processed according to
b5dc1377 478.Ic ntrans
a154ee89 479and
b5dc1377 480.Ic nmap
a154ee89 481settings.
b5dc1377
CL
482exist on the current system, the remote file is considered
483.Ic newer .
484Otherwise, this command is identical to
485.Ar get .
486.Tp Cx Ic nlist
487.Cx \&\ \&
488.Op Ar remote-directory
489.Cx \&\ \&
490.Op Ar local-file
491.Cx
cdc35b45 492Print a list of the files of a
ff00793c 493directory on the remote machine. If
b5dc1377 494.Ar remote-directory
ff00793c
MK
495is left unspecified, the current working directory is used.
496If interactive prompting is on,
b5dc1377 497.Nm ftp
ff00793c
MK
498will prompt the user to verify that the last argument is indeed the
499target local file for receiving
b5dc1377 500.Ic nlist
ff00793c 501output.
b5dc1377
CL
502If no local file is specified, or if
503.Ar local-file
504is
505.Fl ,
ff00793c 506the output is sent to the terminal.
b5dc1377
CL
507.Tp Cx Ic nmap
508.Cx \&\ \&
509.Op Ar inpattern outpattern
510.Cx
a154ee89
GM
511Set or unset the filename mapping mechanism.
512If no arguments are specified, the filename mapping mechanism is unset.
513If arguments are specified, remote filenames are mapped during
b5dc1377 514.Ic mput
a154ee89 515commands and
b5dc1377 516.Ic put
a154ee89
GM
517commands issued without a specified remote target filename.
518If arguments are specified, local filenames are mapped during
b5dc1377 519.Ic mget
a154ee89 520commands and
b5dc1377 521.Ic get
a154ee89
GM
522commands issued without a specified local target filename.
523This command is useful when connecting to a non-UNIX remote computer
524with different file naming conventions or practices.
525The mapping follows the pattern set by
b5dc1377 526.Ar inpattern
a154ee89 527and
b5dc1377
CL
528.Ar outpattern .
529.Op Ar Inpattern
a154ee89
GM
530is a template for incoming filenames (which may have already been
531processed according to the
b5dc1377 532.Ic ntrans
a154ee89 533and
b5dc1377 534.Ic case
a154ee89 535settings).
2c32d7db 536Variable templating is accomplished by including the sequences '$1', '$2', ..., '$9' in
b5dc1377 537.Ar inpattern .
a154ee89
GM
538Use '\\' to prevent this special treatment of the '$' character.
539All other characters are treated literally, and are used to determine the
b5dc1377
CL
540.Ic nmap
541.Op Ar inpattern
a154ee89 542variable values.
ff00793c 543For example, given
b5dc1377 544.Ar inpattern
a154ee89
GM
545$1.$2 and the remote file name "mydata.data", $1 would have the value
546"mydata", and $2 would have the value "data".
547The
b5dc1377 548.Ar outpattern
a154ee89
GM
549determines the resulting mapped filename.
550The sequences '$1', '$2', ...., '$9' are replaced by any value resulting
551from the
b5dc1377 552.Ar inpattern
a154ee89
GM
553template.
554The sequence '$0' is replace by the original filename.
b5dc1377
CL
555Additionally, the sequence
556.Cx `
557.Op Ar seq1 , Ar seq2
558.Cx \'
559is replaced by
560.Op Ar seq1
a154ee89 561if
b5dc1377 562.Ar seq1
a154ee89 563is not a null string; otherwise it is replaced by
b5dc1377
CL
564.Ar seq2 .
565For example, the command
566.Pp
567.Df I
568nmap $1.$2.$3
569.Cx Op $1,$2
570.Cx .
571.Op $2,file
572.Cx
573.De
574.Pp
575would yield
a154ee89
GM
576the output filename "myfile.data" for input filenames "myfile.data" and
577"myfile.data.old", "myfile.file" for the input filename "myfile", and
578"myfile.myfile" for the input filename ".myfile".
579Spaces may be included in
b5dc1377
CL
580.Ar outpattern ,
581as in the example: nmap $1 sed "s/ *$//" > $1 .
a154ee89 582Use the '\\' character to prevent special treatment
b5dc1377
CL
583of the '$','[','[', and ',' characters.
584.Tp Cx Ic ntrans
585.Cx \&\ \&
586.Op Ar inchars Op Ar outchars
587.Cx
a154ee89
GM
588Set or unset the filename character translation mechanism.
589If no arguments are specified, the filename character
590translation mechanism is unset.
591If arguments are specified, characters in
592remote filenames are translated during
b5dc1377 593.Ic mput
a154ee89 594commands and
b5dc1377 595.Ic put
a154ee89
GM
596commands issued without a specified remote target filename.
597If arguments are specified, characters in
598local filenames are translated during
b5dc1377 599.Ic mget
a154ee89 600commands and
b5dc1377 601.Ic get
a154ee89
GM
602commands issued without a specified local target filename.
603This command is useful when connecting to a non-UNIX remote computer
604with different file naming conventions or practices.
605Characters in a filename matching a character in
b5dc1377 606.Ar inchars
a154ee89 607are replaced with the corresponding character in
b5dc1377 608.Ar outchars .
a154ee89 609If the character's position in
b5dc1377 610.Ar inchars
a154ee89 611is longer than the length of
b5dc1377 612.Ar outchars ,
a154ee89 613the character is deleted from the file name.
b5dc1377
CL
614.Tp Cx Ic open
615.Cx \&\ \&
616.Ar host
617.Cx \&\ \&
618.Op Ar port
619.Cx
9e7fc5bf 620Establish a connection to the specified
b5dc1377 621.Ar host
9e7fc5bf 622FTP server. An optional port number may be supplied,
b5dc1377
CL
623in which case,
624.Nm ftp
9e7fc5bf 625will attempt to contact an FTP server at that port.
b5dc1377
CL
626If the
627.Ic auto-login
628option is on (default),
629.Nm ftp
9e7fc5bf
KM
630will also attempt to automatically log the user in to
631the FTP server (see below).
b5dc1377 632.Tp Ic prompt
9e7fc5bf
KM
633Toggle interactive prompting. Interactive prompting
634occurs during multiple file transfers to allow the
1609770c 635user to selectively retrieve or store files.
b5dc1377
CL
636If prompting is turned off (default is on), any
637.Ic mget
638or
639.Ic mput
640will transfer all files, and any
641.Ic mdelete
642will delete all files.
643.Tp Cx Ic proxy
644.Cx \&\ \&
645.Ar ftp-command
646.Cx
a154ee89
GM
647Execute an ftp command on a secondary control connection.
648This command allows simultaneous connection to two remote ftp
649servers for transferring files between the two servers.
650The first
b5dc1377 651.Ic proxy
a154ee89 652command should be an
b5dc1377 653.Ic open ,
a154ee89
GM
654to establish the secondary control connection.
655Enter the command "proxy ?" to see other ftp commands executable on the
656secondary connection.
98a310f2 657The following commands behave differently when prefaced by
b5dc1377
CL
658.Ic proxy :
659.Ic open
a154ee89 660will not define new macros during the auto-login process,
b5dc1377 661.Ic close
a154ee89 662will not erase existing macro definitions,
b5dc1377 663.Ic get
a154ee89 664and
b5dc1377 665.Ic mget
a154ee89
GM
666transfer files from the host on the primary control connection
667to the host on the secondary control connection, and
b5dc1377
CL
668.Ic put ,
669.Ic mput ,
a154ee89 670and
b5dc1377 671.Ic append
a154ee89
GM
672transfer files from the host on the secondary control connection
673to the host on the primary control connection.
674Third party file transfers depend upon support of the ftp protocol
675PASV command by the server on the secondary control connection.
b5dc1377
CL
676.Tp Cx Ic put
677.Cx \&\ \&
678.Ar local-file
679.Cx \&\ \&
680.Op Ar remote-file
681.Cx
682Store a local file on the remote machine. If
683.Ar remote-file
9e7fc5bf 684is left unspecified, the local file name is used
a154ee89 685after processing according to any
b5dc1377 686.Ic ntrans
a154ee89 687or
b5dc1377 688.Ic nmap
a154ee89 689settings
9e7fc5bf 690in naming the remote file. File transfer uses the
a154ee89 691current settings for
b5dc1377
CL
692.Ic type ,
693.Ic format ,
694.Ic mode ,
a154ee89 695and
b5dc1377
CL
696.Ic structure .
697.Tp Ic pwd
9e7fc5bf
KM
698Print the name of the current working directory on the remote
699machine.
b5dc1377 700.Tp Ic quit
3c604e97 701A synonym for
b5dc1377
CL
702.Ic bye .
703.Tp Cx Ic quote
704.Cx \&\ \&
705.Ar crg1 arg2 ...
706.Cx
a154ee89
GM
707The arguments specified are sent, verbatim, to the remote FTP
708server.
b5dc1377
CL
709.Tp Cx Ic recv
710.Cx \&\ \&
711.Ar remote-file
712.Cx \&\ \&
713.Op Ar local-file
714.Cx
a154ee89 715A synonym for get.
b5dc1377
CL
716.Tp Cx Ic remotehelp
717.Cx \&\ \&
718.Op Ar command-name
719.Cx
720Request help from the remote FTP server. If a
721.Ar command-name
9e7fc5bf 722is specified it is supplied to the server as well.
b5dc1377
CL
723.Tp Cx Ic remotestatus
724.Op Ar file-name
725.Cx
726With no arguments, show status of remote machine. If
727.Ar file-name
728is specified, show status of
729.Ar file-name
730on remote machine.
731.Tp Cx Ic rename
732.Cx \&\ \&
733.Op Ar from
734.Cx \&\ \&
735.Op Ar to
736.Cx
9e7fc5bf 737Rename the file
b5dc1377 738.Ar from
a154ee89 739on the remote machine, to the file
b5dc1377
CL
740.Ar to .
741.Tp Ic reset
a154ee89
GM
742Clear reply queue.
743This command re-synchronizes command/reply sequencing with the remote
744ftp server.
ff00793c 745Resynchronization may be necessary following a violation of the ftp protocol
a154ee89 746by the remote server.
b5dc1377
CL
747.Tp Cx Ic rmdir
748.Cx \&\ \&
749.Ar directory-name
750.Cx
9e7fc5bf 751Delete a directory on the remote machine.
b5dc1377 752.Tp Ic runique
a154ee89
GM
753Toggle storing of files on the local system with unique filenames.
754If a file already exists with a name equal to the target
755local filename for a
b5dc1377 756.Ic get
a154ee89 757or
b5dc1377 758.Ic mget
2c32d7db 759command, a ".1" is appended to the name.
a154ee89
GM
760If the resulting name matches another existing file,
761a ".2" is appended to the original name.
762If this process continues up to ".99", an error
763message is printed, and the transfer does not take place.
764The generated unique filename will be reported.
765Note that
b5dc1377 766.Ic runique
a154ee89
GM
767will not affect local files generated from a shell command
768(see below).
769The default value is off.
b5dc1377
CL
770.Tp Cx Ic send
771.Cx \&\ \&
772.Ar local-file
773.Cx \&\ \&
774.Op Ar remote-file
775.Cx
a154ee89 776A synonym for put.
b5dc1377
CL
777.Tp Ic sendport
778Toggle the use of PORT commands. By default,
779.Nm ftp
9e7fc5bf 780will attempt to use a PORT command when establishing
a154ee89
GM
781a connection for each data transfer.
782The use of PORT commands can prevent delays
783when performing multiple file transfers. If the PORT
b5dc1377
CL
784command fails,
785.Nm ftp
9e7fc5bf
KM
786will use the default data port. When the use of PORT
787commands is disabled, no attempt will be made to use
788PORT commands for each data transfer. This is useful
a154ee89
GM
789for certain FTP implementations which do ignore PORT
790commands but, incorrectly, indicate they've been accepted.
b5dc1377
CL
791.Tp Cx Ic site
792.Cx \&\ \&
793.Ar arg1 arg2 ...
794.Cx
23d74d65
MK
795The arguments specified are sent, verbatim, to the remote FTP
796server as a SITE command.
b5dc1377
CL
797.Tp Cx Ic size
798.Cx \&\ \&
799.Ar file-name
800.Cx
801Return size of
802.Ar file-name
803on remote machine.
804.Tp Ic status
9e7fc5bf 805Show the current status of
b5dc1377
CL
806.Nm ftp .
807.Tp Cx Ic struct
808.Cx \&\ \&
809.Op Ar struct-name
810.Cx
a154ee89 811Set the file transfer
b5dc1377 812.Ar structure
a154ee89 813to
b5dc1377
CL
814.Ar struct-name .
815By default \*(Lqstream\*(Rq structure is used.
816.Tp Ic sunique
a154ee89
GM
817Toggle storing of files on remote machine under unique file names.
818Remote ftp server must support ftp protocol STOU command for
819successful completion.
820The remote server will report unique name.
821Default value is off.
b5dc1377 822.Tp Ic system
ff00793c 823Show the type of operating system running on the remote machine.
b5dc1377 824.Tp Ic tenex
a154ee89 825Set the file transfer type to that needed to
9e7fc5bf 826talk to TENEX machines.
b5dc1377 827.Tp Ic trace
a154ee89 828Toggle packet tracing.
b5dc1377
CL
829.Tp Cx Ic type
830.Cx \&\ \&
831.Op Ar type-name
832.Cx
a154ee89 833Set the file transfer
b5dc1377 834.Ic type
a154ee89 835to
b5dc1377 836.Ar type-name .
9e7fc5bf 837If no type is specified, the current type
a154ee89 838is printed. The default type is network ASCII.
b5dc1377
CL
839.Tp Cx Ic umask
840.Cx \&\ \&
841.Op Ar newmask
842.Cx
843Set the default umask on the remote server to
844.Ic newmask .
845If
846.Ic newmask
847is ommitted, the current umask is printed.
848.Tp Cx Ic user
849.Cx \&\ \&
850.Ar user-name
851.Cx \&\ \&
852.Op Ar password
853.Cx \&\ \&
854.Op Ar account
855.Cx
9e7fc5bf
KM
856Identify yourself to the remote FTP server. If the
857password is not specified and the server requires it,
b5dc1377 858.Nm ftp
9e7fc5bf
KM
859will prompt the user for it (after disabling local echo).
860If an account field is not specified, and the FTP server
a154ee89
GM
861requires it, the user will be prompted for it.
862If an account field is specified, an account command will
863be relayed to the remote server after the login sequence
864is completed if the remote server did not require it
865for logging in.
866Unless
b5dc1377
CL
867.Nm ftp
868is invoked with \*(Lqauto-login\*(Rq disabled, this
9e7fc5bf
KM
869process is done automatically on initial connection to
870the FTP server.
b5dc1377 871.Tp Ic verbose
9e7fc5bf
KM
872Toggle verbose mode. In verbose mode, all responses from
873the FTP server are displayed to the user. In addition,
a154ee89 874if verbose is on, when a file transfer completes, statistics
9e7fc5bf 875regarding the efficiency of the transfer are reported. By default,
a154ee89 876verbose is on.
b5dc1377
CL
877.Tp Cx Ic ?
878.Cx \&\ \&
879.Op Ar command
880.Cx
a154ee89 881A synonym for help.
b5dc1377
CL
882.Tp
883.Pp
9e7fc5bf
KM
884Command arguments which have embedded spaces may be quoted with
885quote (") marks.
b5dc1377 886.Sh "ABORTING A FILE TRANSFER"
98a310f2 887To abort a file transfer, use the terminal interrupt key
a154ee89
GM
888(usually Ctrl-C).
889Sending transfers will be immediately halted.
890Receiving transfers will be halted by sending a ftp protocol ABOR
891command to the remote server, and discarding any further data received.
892The speed at which this is accomplished depends upon the remote
893server's support for ABOR processing.
98a310f2 894If the remote server does not support the ABOR command, an "ftp>"
a154ee89
GM
895prompt will not appear until the remote server has completed
896sending the requested file.
b5dc1377 897.Pp
a154ee89 898The terminal interrupt key sequence will be ignored when
b5dc1377 899.Nm ftp
a154ee89
GM
900has completed any local processing and is awaiting a reply
901from the remote server.
902A long delay in this mode may result from the ABOR processing described
903above, or from unexpected behavior by the remote server, including
904violations of the ftp protocol.
905If the delay results from unexpected remote server behavior, the local
b5dc1377 906.Nm ftp
a154ee89 907program must be killed by hand.
b5dc1377 908.Sh "FILE NAMING CONVENTIONS"
a154ee89 909Files specified as arguments to
b5dc1377 910.Nm ftp
9e7fc5bf 911commands are processed according to the following rules.
b5dc1377
CL
912.Tw Fl
913.Tp \&1)
914If the file name \*(Lq\-\*(Rq is specified, the
915.Ar stdin
a154ee89 916(for reading) or
b5dc1377 917.Ar stdout
9e7fc5bf 918(for writing) is used.
b5dc1377
CL
919.Tp \&2)
920If the first character of the file name is \*(Lq\*(Rq, the
9e7fc5bf 921remainder of the argument is interpreted as a shell command.
b5dc1377
CL
922.Nm Ftp
923then forks a shell, using
924.Xr popen 3
a154ee89
GM
925with the argument supplied, and reads (writes) from the stdout
926(stdin). If the shell command includes spaces, the argument
b5dc1377
CL
927must be quoted; e.g. \*(Lq" ls -lt"\*(Rq. A particularly
928useful example of this mechanism is: \*(Lqdir more\*(Rq.
929.Tp \&3)
930Failing the above checks, if ``globbing'' is enabled,
9e7fc5bf 931local file names are expanded
b5dc1377
CL
932according to the rules used in the
933.Xr csh 1 ;
934c.f. the
935.Ic glob
936command.
a154ee89 937If the
b5dc1377 938.Nm ftp
a154ee89 939command expects a single local file ( .e.g.
b5dc1377 940.Ic put ) ,
a154ee89 941only the first filename generated by the "globbing" operation is used.
b5dc1377 942.Tp \&4)
a154ee89 943For
b5dc1377 944.Ic mget
a154ee89 945commands and
b5dc1377 946.Ic get
a154ee89
GM
947commands with unspecified local file names, the local filename is
948the remote filename, which may be altered by a
b5dc1377
CL
949.Ic case ,
950.Ic ntrans ,
a154ee89 951or
b5dc1377 952.Ic nmap
a154ee89
GM
953setting.
954The resulting filename may then be altered if
b5dc1377 955.Ic runique
a154ee89 956is on.
b5dc1377 957.Tp \&5)
a154ee89 958For
b5dc1377 959.Ic mput
a154ee89 960commands and
b5dc1377 961.Ic put
a154ee89
GM
962commands with unspecified remote file names, the remote filename is
963the local filename, which may be altered by a
b5dc1377 964.Ic ntrans
a154ee89 965or
b5dc1377 966.Ic nmap
a154ee89
GM
967setting.
968The resulting filename may then be altered by the remote server if
b5dc1377 969.Ic sunique
a154ee89 970is on.
b5dc1377
CL
971.Tp
972.Sh "FILE TRANSFER PARAMETERS"
9e7fc5bf 973The FTP specification specifies many parameters which may
b5dc1377
CL
974affect a file transfer. The
975.Ic type
976may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
977\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for PDP-10's
a154ee89 978and PDP-20's mostly).
b5dc1377 979.Nm Ftp
a154ee89 980supports the ascii and image types of file transfer,
b5dc1377
CL
981plus local byte size 8 for
982.Ic tenex
983mode transfers.
984.Pp
985.Nm Ftp
a154ee89 986supports only the default values for the remaining
b5dc1377
CL
987file transfer parameters:
988.Ic mode ,
989.Ic form ,
a154ee89 990and
b5dc1377
CL
991.Ic struct .
992.Sh "THE .netrc FILE"
a154ee89 993The
b5dc1377
CL
994.Pa .netrc
995file contains login and initialization information
a154ee89
GM
996used by the auto-login process.
997It resides in the user's home directory.
998The following tokens are recognized; they may be separated by spaces,
999tabs, or new-lines:
b5dc1377
CL
1000.Tw password
1001.Tp Cx Ic machine
1002.Cx \&\ \&
1003.Ar name
1004.Cx
a154ee89
GM
1005Identify a remote machine name.
1006The auto-login process searches the .netrc file for a
b5dc1377 1007.Ic machine
2c32d7db 1008token that matches the remote machine specified on the
b5dc1377 1009.Nm ftp
a154ee89 1010command line or as an
b5dc1377 1011.Ic open
a154ee89 1012command argument.
a154ee89
GM
1013Once a match is made, the subsequent .netrc tokens are processed,
1014stopping when the end of file is reached or another
b5dc1377 1015.Ic machine
cdc35b45 1016or a
b5dc1377 1017.Ic default
a154ee89 1018token is encountered.
b5dc1377
CL
1019.Tp Ic default
1020This is the same as
1021.Ic machine
1022.Ar name
1023except that
1024.Ic default
cdc35b45 1025matches any name.
b5dc1377
CL
1026There can be only one
1027.Ic default
1028token, and it must be after all
1029.Ic machine
1030tokens.
cdc35b45 1031This is normally used as:
b5dc1377
CL
1032.Dl default login anonymous password user@site
1033thereby giving the user
1034.Ar automatic
1035anonymous ftp login to
1036machines not specified in
1037.Pa .netrc .
1038This can be overridden
1039by using the
1040.Fl n
1041flag to disable auto-login.
1042.Tp Cx Ic login
1043.Cx \&\ \&
1044.Ar name
1045.Cx
a154ee89
GM
1046Identify a user on the remote machine.
1047If this token is present, the auto-login process will initiate
1048a login using the specified name.
b5dc1377
CL
1049.Tp Cx Ic password
1050.Cx \&\ \&
1051.Ar string
1052.Cx
a154ee89
GM
1053Supply a password.
1054If this token is present, the auto-login process will supply the
1055specified string if the remote server requires a password as part
1056of the login process.
b5dc1377
CL
1057Note that if this token is present in the
1058.Pa .netrc
1059file for any user other
1060than
1061.Ar anonymous ,
1062.Nm ftp
1063will abort the auto-login process if the
1064.Pa .netrc
1065is readable by
a154ee89 1066anyone besides the user.
b5dc1377
CL
1067.Tp Cx Ic account
1068.Cx \&\ \&
1069.Ar string
1070.Cx
a154ee89
GM
1071Supply an additional account password.
1072If this token is present, the auto-login process will supply the
1073specified string if the remote server requires an additional
1074account password, or the auto-login process will initiate an
1075ACCT command if it does not.
b5dc1377
CL
1076.Tp Cx Ic macdef
1077.Cx \&\ \&
1078.Ar name
1079.Cx
a154ee89
GM
1080Define a macro.
1081This token functions like the
b5dc1377
CL
1082.Nm ftp
1083.Ic macdef
a154ee89
GM
1084command functions.
1085A macro is defined with the specified name; its contents begin with the
b5dc1377
CL
1086next
1087.Pa .netrc
1088line and continue until a null line (consecutive new-line
a154ee89
GM
1089characters) is encountered.
1090If a macro named
b5dc1377 1091.Ic init
a154ee89
GM
1092is defined, it is automatically executed as the last step in the
1093auto-login process.
b5dc1377
CL
1094.Tp
1095.Sh ENVIRONMENT
1096.Nm Ftp
1097makes use of the
1098.Ev HOME
1099and
1100.Ev SHELL
1101environment variables.
1102.Sh SEE ALSO
1103.Xr ftpd 8
1104.Sh HISTORY
1105.Nm Ftp
1106appeared in 4.2 BSD.
1107.Sh BUGS
a154ee89
GM
1108Correct execution of many commands depends upon proper behavior
1109by the remote server.
b5dc1377 1110.Pp
98a310f2
MK
1111An error in the treatment of carriage returns
1112in the 4.2BSD UNIX ascii-mode transfer code
a154ee89
GM
1113has been corrected.
1114This correction may result in incorrect transfers of binary files
98a310f2 1115to and from 4.2BSD servers using the ascii type.
a154ee89 1116Avoid this problem by using the binary image type.