xref: /csrg-svn/usr.bin/ftp/ftp.1 (revision 62009)
1*62009Sbostic.\" Copyright (c) 1985, 1989, 1990, 1993
2*62009Sbostic.\"	The Regents of the University of California.  All rights reserved.
319706Smckusick.\"
450621Scael.\" %sccs.include.redist.roff%
519706Smckusick.\"
6*62009Sbostic.\"	@(#)ftp.1	8.1 (Berkeley) 06/06/93
735630Sbostic.\"
843083Scael.Dd
943083Scael.Dt FTP 1
1043083Scael.Os BSD 4.2
1143083Scael.Sh NAME
1243083Scael.Nm ftp
1350621Scael.Nd
1450621Scael.Tn ARPANET
1550621Scaelfile transfer program
1643083Scael.Sh SYNOPSIS
1743083Scael.Nm ftp
1843083Scael.Op Fl v
1943083Scael.Op Fl d
2043083Scael.Op Fl i
2143083Scael.Op Fl n
2243083Scael.Op Fl g
2343083Scael.Op Ar host
2443083Scael.Sh DESCRIPTION
2543083Scael.Nm Ftp
2650621Scaelis the user interface to the
2750621Scael.Tn ARPANET
2850621Scaelstandard File Transfer Protocol.
2926050SminshallThe program allows a user to transfer files to and from a
3026050Sminshallremote network site.
3143083Scael.Pp
3243083ScaelOptions may be specified at the command line, or to the
3343083Scaelcommand interpreter.
3450621Scael.Bl -tag -width flag
3550621Scael.It Fl v
3643083ScaelVerbose option forces
3743083Scael.Nm ftp
3843083Scaelto show all responses from the remote server, as well
3943083Scaelas report on data transfer statistics.
4050621Scael.It Fl n
4143083ScaelRestrains
4243083Scael.Nm ftp
4343083Scaelfrom attempting \*(Lqauto-login\*(Rq upon initial connection.
4443083ScaelIf auto-login is enabled,
4543083Scael.Nm ftp
4643083Scaelwill check the
4743083Scael.Pa .netrc
4843083Scael(see below) file in the user's home directory for an entry describing
4950621Scaelan account on the remote machine.
5050621ScaelIf no entry exists,
5143083Scael.Nm ftp
5243083Scaelwill prompt for the remote machine login name (default is the user
5343083Scaelidentity on the local machine), and, if necessary, prompt for a password
5443083Scaeland an account with which to login.
5550621Scael.It Fl i
5643083ScaelTurns off interactive prompting during
5743083Scaelmultiple file transfers.
5850621Scael.It Fl d
5943083ScaelEnables debugging.
6050621Scael.It Fl g
6143083ScaelDisables file name globbing.
6250621Scael.El
6343083Scael.Pp
6443083ScaelThe client host with which
6543083Scael.Nm ftp
6619706Smckusickis to communicate may be specified on the command line.
6719706SmckusickIf this is done,
6843083Scael.Nm ftp
6950621Scaelwill immediately attempt to establish a connection to an
7050621Scael.Tn FTP
7143083Scaelserver on that host; otherwise,
7243083Scael.Nm ftp
7326050Sminshallwill enter its command interpreter and await instructions
7450621Scaelfrom the user.
7550621ScaelWhen
7643083Scael.Nm ftp
7744954Scaelis awaiting commands from the user the prompt
7844954Scael.Ql ftp>
7950621Scaelis provided to the user.
8050621ScaelThe following commands are recognized
8119706Smckusickby
8243083Scael.Nm ftp  :
8350621Scael.Bl -tag -width Fl
8450621Scael.It Ic \&! Op Ar command Op Ar args
8526050SminshallInvoke an interactive shell on the local machine.
8626050SminshallIf there are arguments, the first is taken to be a command to execute
8726050Sminshalldirectly, with the rest of the arguments as its arguments.
8850621Scael.It Ic \&$ Ar macro-name Op Ar args
8943083ScaelExecute the macro
9043083Scael.Ar macro-name
9143083Scaelthat was defined with the
9243083Scael.Ic macdef
9343083Scaelcommand.
9426050SminshallArguments are passed to the macro unglobbed.
9550621Scael.It Ic account Op Ar passwd
9626050SminshallSupply a supplemental password required by a remote system for access
9726050Sminshallto resources once a login has been successfully completed.
9826050SminshallIf no argument is included, the user will be prompted for an account
9926050Sminshallpassword in a non-echoing input mode.
10050621Scael.It Ic append Ar local-file Op Ar remote-file
10150621ScaelAppend a local file to a file on the remote machine.
10250621ScaelIf
10343083Scael.Ar remote-file
10419706Smckusickis left unspecified, the local file name is used in naming the
10526050Sminshallremote file after being altered by any
10643083Scael.Ic ntrans
10726050Sminshallor
10843083Scael.Ic nmap
10926050Sminshallsetting.
11026050SminshallFile transfer uses the current settings for
11143083Scael.Ic type  ,
11243083Scael.Ic format ,
11343083Scael.Ic mode  ,
11426050Sminshalland
11544954Scael.Ic structure .
11650621Scael.It Ic ascii
11743083ScaelSet the file transfer
11843083Scael.Ic type
11950621Scaelto network
12050621Scael.Tn ASCII .
12150621ScaelThis is the default type.
12250621Scael.It Ic bell
12319706SmckusickArrange that a bell be sounded after each file transfer
12419706Smckusickcommand is completed.
12550621Scael.It Ic binary
12626050SminshallSet the file transfer
12743083Scael.Ic type
12826050Sminshallto support binary image transfer.
12950621Scael.It Ic bye
13050621ScaelTerminate the
13150621Scael.Tn FTP
13250621Scaelsession with the remote server
13319706Smckusickand exit
13443083Scael.Nm ftp  .
13526085SlepreauAn end of file will also terminate the session and exit.
13650621Scael.It Ic case
13726050SminshallToggle remote computer file name case mapping during
13843083Scael.Ic mget
13926050Sminshallcommands.
14026050SminshallWhen
14143083Scael.Ic case
14226050Sminshallis on (default is off), remote computer file names with all letters in
14326050Sminshallupper case are written in the local directory with the letters mapped
14426050Sminshallto lower case.
14550621Scael.It Ic \&cd Ar remote-directory
14619706SmckusickChange the working directory on the remote machine
14743083Scaelto
14843083Scael.Ar remote-directory  .
14950621Scael.It Ic cdup
15026050SminshallChange the remote machine working directory to the parent of the
15126050Sminshallcurrent remote machine working directory.
15250621Scael.It Ic chmod Ar mode file-name
15344954ScaelChange the permission modes of the file
15443083Scael.Ar file-name
15543083Scaelon the remote
15643083Scaelsytem to
15744954Scael.Ar mode  .
15850621Scael.It Ic close
15950621ScaelTerminate the
16050621Scael.Tn FTP
16150621Scaelsession with the remote server, and
16219706Smckusickreturn to the command interpreter.
16326050SminshallAny defined macros are erased.
16450621Scael.It Ic \&cr
16526050SminshallToggle carriage return stripping during
16626050Sminshallascii type file retrieval.
16726050SminshallRecords are denoted by a carriage return/linefeed sequence
16826050Sminshallduring ascii type file transfer.
16926050SminshallWhen
17050621Scael.Ic \&cr
17126050Sminshallis on (the default), carriage returns are stripped from this
17250621Scaelsequence to conform with the
17350621Scael.Ux
17450621Scaelsingle linefeed record
17526050Sminshalldelimiter.
17650621ScaelRecords on
17750621Scael.Pf non\- Ns Ux
17850621Scaelremote systems may contain single linefeeds;
17926050Sminshallwhen an ascii type transfer is made, these linefeeds may be
18026050Sminshalldistinguished from a record delimiter only when
18150621Scael.Ic \&cr
18226050Sminshallis off.
18350621Scael.It Ic delete Ar remote-file
18419706SmckusickDelete the file
18543083Scael.Ar remote-file
18619706Smckusickon the remote machine.
18750621Scael.It Ic debug Op Ar debug-value
18850621ScaelToggle debugging mode.
18950621ScaelIf an optional
19043083Scael.Ar debug-value
19119706Smckusickis specified it is used to set the debugging level.
19219706SmckusickWhen debugging is on,
19343083Scael.Nm ftp
19419706Smckusickprints each command sent to the remote machine, preceded
19544954Scaelby the string
19644954Scael.Ql \-\->
19750621Scael.It Xo
19850621Scael.Ic dir
19943083Scael.Op Ar remote-directory
20043083Scael.Op Ar local-file
20150621Scael.Xc
20219706SmckusickPrint a listing of the directory contents in the
20319706Smckusickdirectory,
20443083Scael.Ar remote-directory  ,
20519706Smckusickand, optionally, placing the output in
20643083Scael.Ar local-file  .
20732345SbosticIf interactive prompting is on,
20843083Scael.Nm ftp
20932345Sbosticwill prompt the user to verify that the last argument is indeed the
21032345Sbostictarget local file for receiving
21143083Scael.Ic dir
21232345Sbosticoutput.
21319706SmckusickIf no directory is specified, the current working
21450621Scaeldirectory on the remote machine is used.
21550621ScaelIf no local
21643083Scaelfile is specified, or
21743083Scael.Ar local-file
21843083Scaelis
21943083Scael.Fl  ,
22019707Smckusickoutput comes to the terminal.
22150621Scael.It Ic disconnect
22226050SminshallA synonym for
22343083Scael.Ar close  .
22450621Scael.It Ic form Ar format
22543083ScaelSet the file transfer
22643083Scael.Ic form
22743083Scaelto
22843083Scael.Ar format  .
22943083ScaelThe default format is \*(Lqfile\*(Rq.
23050621Scael.It Ic get Ar remote-file Op Ar local-file
23143083ScaelRetrieve the
23243083Scael.Ar remote-file
23350621Scaeland store it on the local machine.
23450621ScaelIf the local
23519706Smckusickfile name is not specified, it is given the same
23626050Sminshallname it has on the remote machine, subject to
23726050Sminshallalteration by the current
23843083Scael.Ic case  ,
23943083Scael.Ic ntrans ,
24026050Sminshalland
24143083Scael.Ic nmap
24226050Sminshallsettings.
24343083ScaelThe current settings for
24443083Scael.Ic type  ,
24543083Scael.Ic form ,
24643083Scael.Ic mode  ,
24726050Sminshalland
24843083Scael.Ic structure
24919706Smckusickare used while transferring the file.
25050621Scael.It Ic glob
25143083ScaelToggle filename expansion for
25243083Scael.Ic mdelete  ,
25343083Scael.Ic mget
25443083Scaeland
25543083Scael.Ic mput  .
25643083ScaelIf globbing is turned off with
25743083Scael.Ic glob  ,
25843083Scaelthe file name arguments
25926050Sminshallare taken literally and not expanded.
26043083ScaelGlobbing for
26143083Scael.Ic mput
26243083Scaelis done as in
26343083Scael.Xr csh 1 .
26443083ScaelFor
26543083Scael.Ic mdelete
26643083Scaeland
26743083Scael.Ic mget  ,
26843083Scaeleach remote file name is expanded
26926050Sminshallseparately on the remote machine and the lists are not merged.
27043083ScaelExpansion of a directory name is likely to be
27119707Smckusickdifferent from expansion of the name of an ordinary file:
27226050Sminshallthe exact result depends on the foreign operating system and ftp server,
27343083Scaeland can be previewed by doing
27444954Scael.Ql mls remote-files \-
27543083ScaelNote:
27643083Scael.Ic mget
27743083Scaeland
27843083Scael.Ic mput
27943083Scaelare not meant to transfer
28050621Scaelentire directory subtrees of files.
28150621ScaelThat can be done by
28243083Scaeltransferring a
28343083Scael.Xr tar 1
28443083Scaelarchive of the subtree (in binary mode).
28550621Scael.It Ic hash
28619706SmckusickToggle hash-sign (``#'') printing for each data block
28750621Scaeltransferred.
28850621ScaelThe size of a data block is 1024 bytes.
28950621Scael.It Ic help Op Ar command
29019706SmckusickPrint an informative message about the meaning of
29143083Scael.Ar command  .
29243083ScaelIf no argument is given,
29343083Scael.Nm ftp
29419706Smckusickprints a list of the known commands.
29550621Scael.It Ic idle Op Ar seconds
29643083ScaelSet the inactivity timer on the remote server to
29743083Scael.Ar seconds
29843083Scaelseconds.
29943083ScaelIf
30043083Scael.Ar seconds
30143083Scaelis ommitted, the current inactivity timer is printed.
30250621Scael.It Ic lcd Op Ar directory
30350621ScaelChange the working directory on the local machine.
30450621ScaelIf
30543083Scaelno
30643083Scael.Ar directory
30719706Smckusickis specified, the user's home directory is used.
30850621Scael.It Xo
30950621Scael.Ic \&ls
31043083Scael.Op Ar remote-directory
31143083Scael.Op Ar local-file
31250621Scael.Xc
31336935SkarelsPrint a listing of the contents of a
31436940Skarelsdirectory on the remote machine.
31536940SkarelsThe listing includes any system-dependent information that the server
31650621Scaelchooses to include; for example, most
31750621Scael.Ux
31850621Scaelsystems will produce
31944954Scaeloutput from the command
32044954Scael.Ql ls \-l .
32143083Scael(See also
32250621Scael.Ic nlist . )
32336940SkarelsIf
32443083Scael.Ar remote-directory
32532345Sbosticis left unspecified, the current working directory is used.
32632345SbosticIf interactive prompting is on,
32743083Scael.Nm ftp
32832345Sbosticwill prompt the user to verify that the last argument is indeed the
32932345Sbostictarget local file for receiving
33050621Scael.Ic \&ls
33132345Sbosticoutput.
33243083ScaelIf no local file is specified, or if
33343083Scael.Ar local-file
33443083Scaelis
33544954Scael.Sq Fl ,
33619707Smckusickthe output is sent to the terminal.
33750621Scael.It Ic macdefNs Ar macro-name
33826050SminshallDefine a macro.
33926050SminshallSubsequent lines are stored as the macro
34043083Scael.Ar macro-name  ;
34143083Scaela null line (consecutive newline characters
34226050Sminshallin a file or
34326050Sminshallcarriage returns from the terminal) terminates macro input mode.
34426050SminshallThere is a limit of 16 macros and 4096 total characters in all
34526050Sminshalldefined macros.
34626050SminshallMacros remain defined until a
34743083Scael.Ic close
34826050Sminshallcommand is executed.
34944954ScaelThe macro processor interprets `$' and `\e' as special characters.
35044954ScaelA `$' followed by a number (or numbers) is replaced by the
35126050Sminshallcorresponding argument on the macro invocation command line.
35244954ScaelA `$' followed by an `i' signals that macro processor that the
35350621Scaelexecuting macro is to be looped.
35450621ScaelOn the first pass `$i' is
35526050Sminshallreplaced by the first argument on the macro invocation command line,
35626050Sminshallon the second pass it is replaced by the second argument, and so on.
35744954ScaelA `\e' followed by any character is replaced by that character.
35844954ScaelUse the `\e' to prevent special treatment of the `$'.
35950621Scael.It Ic mdelete Op Ar remote-files
36043083ScaelDelete the
36143083Scael.Ar remote-files
36243083Scaelon the remote machine.
36350621Scael.It Ic mdir Ar remote-files local-file
36443083ScaelLike
36543083Scael.Ic dir  ,
36643083Scaelexcept multiple remote files may be specified.
36726050SminshallIf interactive prompting is on,
36843083Scael.Nm ftp
36926050Sminshallwill prompt the user to verify that the last argument is indeed the
37026050Sminshalltarget local file for receiving
37143083Scael.Ic mdir
37226050Sminshalloutput.
37350621Scael.It Ic mget Ar remote-files
37443083ScaelExpand the
37543083Scael.Ar remote-files
37643083Scaelon the remote machine
37743083Scaeland do a
37843083Scael.Ic get
37943083Scaelfor each file name thus produced.
38043083ScaelSee
38143083Scael.Ic glob
38243083Scaelfor details on the filename expansion.
38326050SminshallResulting file names will then be processed according to
38443083Scael.Ic case  ,
38543083Scael.Ic ntrans ,
38626050Sminshalland
38743083Scael.Ic nmap
38826050Sminshallsettings.
38919707SmckusickFiles are transferred into the local working directory,
39043083Scaelwhich can be changed with
39150621Scael.Ql lcd directory ;
39243083Scaelnew local directories can be created with
39350621Scael.Ql "\&! mkdir directory" .
39450621Scael.It Ic mkdir Ar directory-name
39519706SmckusickMake a directory on the remote machine.
39650621Scael.It Ic mls Ar remote-files local-file
39743083ScaelLike
39843083Scael.Ic nlist  ,
39943083Scaelexcept multiple remote files may be specified,
40043083Scaeland the
40143083Scael.Ar local-file
40243083Scaelmust be specified.
40326050SminshallIf interactive prompting is on,
40443083Scael.Nm ftp
40526050Sminshallwill prompt the user to verify that the last argument is indeed the
40626050Sminshalltarget local file for receiving
40743083Scael.Ic mls
40826050Sminshalloutput.
40950621Scael.It Ic mode Op Ar mode-name
41026050SminshallSet the file transfer
41143083Scael.Ic mode
41226050Sminshallto
41343083Scael.Ar mode-name  .
41443083ScaelThe default mode is \*(Lqstream\*(Rq mode.
41550621Scael.It Ic modtime Ar file-name
41636935SkarelsShow the last modification time of the file on the remote machine.
41750621Scael.It Ic mput Ar local-files
41819707SmckusickExpand wild cards in the list of local files given as arguments
41943083Scaeland do a
42043083Scael.Ic put
42143083Scaelfor each file in the resulting list.
42243083ScaelSee
42343083Scael.Ic glob
42443083Scaelfor details of filename expansion.
42526050SminshallResulting file names will then be processed according to
42643083Scael.Ic ntrans
42726050Sminshalland
42843083Scael.Ic nmap
42926050Sminshallsettings.
43050621Scael.It Ic newer Ar file-name
43137224SkarelsGet the file only if the modification time of the remote file is more
43250621Scaelrecent that the file on the current system.
43350621ScaelIf the file does not
43443083Scaelexist on the current system, the remote file is considered
43543083Scael.Ic newer  .
43643083ScaelOtherwise, this command is identical to
43743083Scael.Ar get  .
43850621Scael.It Xo
43950621Scael.Ic nlist
44043083Scael.Op Ar remote-directory
44143083Scael.Op Ar local-file
44250621Scael.Xc
44344954ScaelPrint a  list of the files in a
44450621Scaeldirectory on the remote machine.
44550621ScaelIf
44643083Scael.Ar remote-directory
44736935Skarelsis left unspecified, the current working directory is used.
44836935SkarelsIf interactive prompting is on,
44943083Scael.Nm ftp
45036935Skarelswill prompt the user to verify that the last argument is indeed the
45136935Skarelstarget local file for receiving
45243083Scael.Ic nlist
45336935Skarelsoutput.
45443083ScaelIf no local file is specified, or if
45543083Scael.Ar local-file
45643083Scaelis
45743083Scael.Fl  ,
45836935Skarelsthe output is sent to the terminal.
45950621Scael.It Ic nmap Op Ar inpattern outpattern
46026050SminshallSet or unset the filename mapping mechanism.
46126050SminshallIf no arguments are specified, the filename mapping mechanism is unset.
46226050SminshallIf arguments are specified, remote filenames are mapped during
46343083Scael.Ic mput
46426050Sminshallcommands and
46543083Scael.Ic put
46626050Sminshallcommands issued without a specified remote target filename.
46726050SminshallIf arguments are specified, local filenames are mapped during
46843083Scael.Ic mget
46926050Sminshallcommands and
47043083Scael.Ic get
47126050Sminshallcommands issued without a specified local target filename.
47250621ScaelThis command is useful when connecting to a
47350621Scael.No non\- Ns Ux
47450621Scaelremote computer
47526050Sminshallwith different file naming conventions or practices.
47626050SminshallThe mapping follows the pattern set by
47743083Scael.Ar inpattern
47826050Sminshalland
47943083Scael.Ar outpattern  .
48043083Scael.Op Ar Inpattern
48126050Sminshallis a template for incoming filenames (which may have already been
48226050Sminshallprocessed according to the
48343083Scael.Ic ntrans
48426050Sminshalland
48543083Scael.Ic case
48626050Sminshallsettings).
48750621ScaelVariable templating is accomplished by including the
48850621Scaelsequences `$1', `$2', ..., `$9' in
48943083Scael.Ar inpattern  .
49044954ScaelUse `\\' to prevent this special treatment of the `$' character.
49126050SminshallAll other characters are treated literally, and are used to determine the
49243083Scael.Ic nmap
49343083Scael.Op Ar inpattern
49426050Sminshallvariable values.
49536935SkarelsFor example, given
49643083Scael.Ar inpattern
49726050Sminshall$1.$2 and the remote file name "mydata.data", $1 would have the value
49826050Sminshall"mydata", and $2 would have the value "data".
49926050SminshallThe
50043083Scael.Ar outpattern
50126050Sminshalldetermines the resulting mapped filename.
50244954ScaelThe sequences `$1', `$2', ...., `$9' are replaced by any value resulting
50326050Sminshallfrom the
50443083Scael.Ar inpattern
50526050Sminshalltemplate.
50644954ScaelThe sequence `$0' is replace by the original filename.
50743083ScaelAdditionally, the sequence
50850621Scael.Ql Op Ar seq1 , Ar seq2
50943083Scaelis replaced by
51043083Scael.Op Ar seq1
51126050Sminshallif
51243083Scael.Ar seq1
51326050Sminshallis not a null string; otherwise it is replaced by
51443083Scael.Ar seq2 .
51543083ScaelFor example, the command
51643083Scael.Pp
51750621Scael.Bd -literal -offset indent -compact
51850621Scaelnmap $1.$2.$3 [$1,$2].[$2,file]
51950621Scael.Ed
52043083Scael.Pp
52143083Scaelwould yield
52226050Sminshallthe output filename "myfile.data" for input filenames "myfile.data" and
52326050Sminshall"myfile.data.old", "myfile.file" for the input filename "myfile", and
52426050Sminshall"myfile.myfile" for the input filename ".myfile".
52526050SminshallSpaces may be included in
52643083Scael.Ar outpattern  ,
52744954Scaelas in the example: `nmap $1 sed "s/  *$//" > $1' .
52844954ScaelUse the `\e' character to prevent special treatment
52944954Scaelof the `$','[','[', and `,' characters.
53050621Scael.It Ic ntrans Op Ar inchars Op Ar outchars
53126050SminshallSet or unset the filename character translation mechanism.
53226050SminshallIf no arguments are specified, the filename character
53326050Sminshalltranslation mechanism is unset.
53426050SminshallIf arguments are specified, characters in
53526050Sminshallremote filenames are translated during
53643083Scael.Ic mput
53726050Sminshallcommands and
53843083Scael.Ic put
53926050Sminshallcommands issued without a specified remote target filename.
54026050SminshallIf arguments are specified, characters in
54126050Sminshalllocal filenames are translated during
54243083Scael.Ic mget
54326050Sminshallcommands and
54443083Scael.Ic get
54526050Sminshallcommands issued without a specified local target filename.
54650621ScaelThis command is useful when connecting to a
54750621Scael.No non\- Ns Ux
54850621Scaelremote computer
54926050Sminshallwith different file naming conventions or practices.
55026050SminshallCharacters in a filename matching a character in
55143083Scael.Ar inchars
55226050Sminshallare replaced with the corresponding character in
55343083Scael.Ar outchars  .
55426050SminshallIf the character's position in
55543083Scael.Ar inchars
55626050Sminshallis longer than the length of
55743083Scael.Ar outchars  ,
55826050Sminshallthe character is deleted from the file name.
55950621Scael.It Ic open Ar host Op Ar port
56019706SmckusickEstablish a connection to the specified
56143083Scael.Ar host
56250621Scael.Tn FTP
56350621Scaelserver.
56450621ScaelAn optional port number may be supplied,
56543083Scaelin which case,
56643083Scael.Nm ftp
56750621Scaelwill attempt to contact an
56850621Scael.Tn FTP
56950621Scaelserver at that port.
57043083ScaelIf the
57143083Scael.Ic auto-login
57243083Scaeloption is on (default),
57343083Scael.Nm ftp
57419706Smckusickwill also attempt to automatically log the user in to
57550621Scaelthe
57650621Scael.Tn FTP
57750621Scaelserver (see below).
57850621Scael.It Ic prompt
57950621ScaelToggle interactive prompting.
58050621ScaelInteractive prompting
58119706Smckusickoccurs during multiple file transfers to allow the
58219707Smckusickuser to selectively retrieve or store files.
58343083ScaelIf prompting is turned off (default is on), any
58443083Scael.Ic mget
58543083Scaelor
58643083Scael.Ic mput
58743083Scaelwill transfer all files, and any
58843083Scael.Ic mdelete
58943083Scaelwill delete all files.
59050621Scael.It Ic proxy Ar ftp-command
59126050SminshallExecute an ftp command on a secondary control connection.
59226050SminshallThis command allows simultaneous connection to two remote ftp
59326050Sminshallservers for transferring files between the two servers.
59426050SminshallThe first
59543083Scael.Ic proxy
59626050Sminshallcommand should be an
59743083Scael.Ic open  ,
59826050Sminshallto establish the secondary control connection.
59926050SminshallEnter the command "proxy ?" to see other ftp commands executable on the
60026050Sminshallsecondary connection.
60127895SkarelsThe following commands behave differently when prefaced by
60243083Scael.Ic proxy  :
60343083Scael.Ic open
60426050Sminshallwill not define new macros during the auto-login process,
60543083Scael.Ic close
60626050Sminshallwill not erase existing macro definitions,
60743083Scael.Ic get
60826050Sminshalland
60943083Scael.Ic mget
61026050Sminshalltransfer files from the host on the primary control connection
61126050Sminshallto the host on the secondary control connection, and
61243083Scael.Ic put  ,
61343083Scael.Ic mput ,
61426050Sminshalland
61543083Scael.Ic append
61626050Sminshalltransfer files from the host on the secondary control connection
61726050Sminshallto the host on the primary control connection.
61826050SminshallThird party file transfers depend upon support of the ftp protocol
61950621Scael.Dv PASV
62050621Scaelcommand by the server on the secondary control connection.
62150621Scael.It Ic put Ar local-file Op Ar remote-file
62250621ScaelStore a local file on the remote machine.
62350621ScaelIf
62443083Scael.Ar remote-file
62519706Smckusickis left unspecified, the local file name is used
62626050Sminshallafter processing according to any
62743083Scael.Ic ntrans
62826050Sminshallor
62943083Scael.Ic nmap
63026050Sminshallsettings
63150621Scaelin naming the remote file.
63250621ScaelFile transfer uses the
63326050Sminshallcurrent settings for
63443083Scael.Ic type  ,
63543083Scael.Ic format ,
63643083Scael.Ic mode  ,
63726050Sminshalland
63843083Scael.Ic structure  .
63950621Scael.It Ic pwd
64019706SmckusickPrint the name of the current working directory on the remote
64119706Smckusickmachine.
64250621Scael.It Ic quit
64326085SlepreauA synonym for
64443083Scael.Ic bye  .
64550621Scael.It Ic quote Ar arg1 arg2 ...
64650621ScaelThe arguments specified are sent, verbatim, to the remote
64750621Scael.Tn FTP
64826050Sminshallserver.
64950621Scael.It Ic recv Ar remote-file Op Ar local-file
65026050SminshallA synonym for get.
65150621Scael.It Ic reget Ar remote-file Op Ar local-file
65243083ScaelReget acts like get, except that if
65343083Scael.Ar local-file
65443083Scaelexists and is
65543083Scaelsmaller than
65643083Scael.Ar remote-file  ,
65743083Scael.Ar local-file
65843083Scaelis presumed to be
65943083Scaela partially transferred copy of
66043083Scael.Ar remote-file
66143083Scaeland the transfer
66250621Scaelis continued from the apparent point of failure.
66350621ScaelThis command
66437224Skarelsis useful when transferring very large files over networks that
66537224Skarelsare prone to dropping connections.
66650621Scael.It Ic remotehelp Op Ar command-name
66750621ScaelRequest help from the remote
66850621Scael.Tn FTP
66950621Scaelserver.
67050621ScaelIf a
67143083Scael.Ar command-name
67219706Smckusickis specified it is supplied to the server as well.
67350621Scael.It Ic remotestatus Op Ar file-name
67450621ScaelWith no arguments, show status of remote machine.
67550621ScaelIf
67643083Scael.Ar file-name
67743083Scaelis specified, show status of
67843083Scael.Ar file-name
67943083Scaelon remote machine.
68050621Scael.It Xo
68150621Scael.Ic rename
68243083Scael.Op Ar from
68343083Scael.Op Ar to
68450621Scael.Xc
68519706SmckusickRename the file
68643083Scael.Ar from
68726050Sminshallon the remote machine, to the file
68843083Scael.Ar to  .
68950621Scael.It Ic reset
69026050SminshallClear reply queue.
69126050SminshallThis command re-synchronizes command/reply sequencing with the remote
69226050Sminshallftp server.
69336935SkarelsResynchronization may be necessary following a violation of the ftp protocol
69426050Sminshallby the remote server.
69550621Scael.It Ic restart Ar marker
69643083ScaelRestart the immediately following
69743083Scael.Ic get
69843083Scaelor
69943083Scael.Ic put
70043083Scaelat the
70143083Scaelindicated
70243083Scael.Ar marker  .
70350621ScaelOn
70450621Scael.Ux
70550621Scaelsystems, marker is usually a byte
70637224Skarelsoffset into the file.
70750621Scael.It Ic rmdir Ar directory-name
70819706SmckusickDelete a directory on the remote machine.
70950621Scael.It Ic runique
71026050SminshallToggle storing of files on the local system with unique filenames.
71126050SminshallIf a file already exists with a name equal to the target
71226050Sminshalllocal filename for a
71343083Scael.Ic get
71426050Sminshallor
71543083Scael.Ic mget
71626491Sminshallcommand, a ".1" is appended to the name.
71726050SminshallIf the resulting name matches another existing file,
71826050Sminshalla ".2" is appended to the original name.
71926050SminshallIf this process continues up to ".99", an error
72026050Sminshallmessage is printed, and the transfer does not take place.
72126050SminshallThe generated unique filename will be reported.
72226050SminshallNote that
72343083Scael.Ic runique
72426050Sminshallwill not affect local files generated from a shell command
72526050Sminshall(see below).
72626050SminshallThe default value is off.
72750621Scael.It Ic send Ar local-file Op Ar remote-file
72826050SminshallA synonym for put.
72950621Scael.It Ic sendport
73050621ScaelToggle the use of
73150621Scael.Dv PORT
73250621Scaelcommands.
73350621ScaelBy default,
73443083Scael.Nm ftp
73550621Scaelwill attempt to use a
73650621Scael.Dv PORT
73750621Scaelcommand when establishing
73826050Sminshalla connection for each data transfer.
73950621ScaelThe use of
74050621Scael.Dv PORT
74150621Scaelcommands can prevent delays
74250621Scaelwhen performing multiple file transfers.
74350621ScaelIf the
74450621Scael.Dv PORT
74543083Scaelcommand fails,
74643083Scael.Nm ftp
74750621Scaelwill use the default data port.
74850621ScaelWhen the use of
74950621Scael.Dv PORT
75019706Smckusickcommands is disabled, no attempt will be made to use
75150621Scael.Dv PORT
75250621Scaelcommands for each data transfer.
75350621ScaelThis is useful
75450621Scaelfor certain
75550621Scael.Tn FTP
75650621Scaelimplementations which do ignore
75750621Scael.Dv PORT
75826050Sminshallcommands but, incorrectly, indicate they've been accepted.
75950621Scael.It Ic site Ar arg1 arg2 ...
76050621ScaelThe arguments specified are sent, verbatim, to the remote
76150621Scael.Tn FTP
76250621Scaelserver as a
76350621Scael.Dv SITE
76450621Scaelcommand.
76550621Scael.It Ic size Ar file-name
76643083ScaelReturn size of
76743083Scael.Ar file-name
76843083Scaelon remote machine.
76950621Scael.It Ic status
77019706SmckusickShow the current status of
77143083Scael.Nm ftp  .
77250621Scael.It Ic struct Op Ar struct-name
77326050SminshallSet the file transfer
77443083Scael.Ar structure
77526050Sminshallto
77644954Scael.Ar struct-name .
77743083ScaelBy default \*(Lqstream\*(Rq structure is used.
77850621Scael.It Ic sunique
77926050SminshallToggle storing of files on remote machine under unique file names.
78050621ScaelRemote ftp server must support ftp protocol
78150621Scael.Dv STOU
78250621Scaelcommand for
78326050Sminshallsuccessful completion.
78426050SminshallThe remote server will report unique name.
78526050SminshallDefault value is off.
78650621Scael.It Ic system
78736935SkarelsShow the type of operating system running on the remote machine.
78850621Scael.It Ic tenex
78926050SminshallSet the file transfer type to that needed to
79050621Scaeltalk to
79150621Scael.Tn TENEX
79250621Scaelmachines.
79350621Scael.It Ic trace
79426050SminshallToggle packet tracing.
79550621Scael.It Ic type Op Ar type-name
79626050SminshallSet the file transfer
79743083Scael.Ic type
79826050Sminshallto
79943083Scael.Ar type-name  .
80019706SmckusickIf no type is specified, the current type
80150621Scaelis printed.
80250621ScaelThe default type is network
80350621Scael.Tn ASCII .
80450621Scael.It Ic umask Op Ar newmask
80543083ScaelSet the default umask on the remote server to
80644954Scael.Ar newmask  .
80743083ScaelIf
80844954Scael.Ar newmask
80943083Scaelis ommitted, the current umask is printed.
81050621Scael.It Xo
81150621Scael.Ic user Ar user-name
81243083Scael.Op Ar password
81343083Scael.Op Ar account
81450621Scael.Xc
81550621ScaelIdentify yourself to the remote
81650621Scael.Tn FTP
81750621Scaelserver.
81850621ScaelIf the
81944954Scael.Ar password
82044954Scaelis not specified and the server requires it,
82143083Scael.Nm ftp
82219706Smckusickwill prompt the user for it (after disabling local echo).
82344954ScaelIf an
82444954Scael.Ar account
82550621Scaelfield is not specified, and the
82650621Scael.Tn FTP
82750621Scaelserver
82826050Sminshallrequires it, the user will be prompted for it.
82944954ScaelIf an
83044954Scael.Ar account
83144954Scaelfield is specified, an account command will
83226050Sminshallbe relayed to the remote server after the login sequence
83326050Sminshallis completed if the remote server did not require it
83426050Sminshallfor logging in.
83526050SminshallUnless
83643083Scael.Nm ftp
83743083Scaelis invoked with \*(Lqauto-login\*(Rq disabled, this
83819706Smckusickprocess is done automatically on initial connection to
83950621Scaelthe
84050621Scael.Tn FTP
84150621Scaelserver.
84250621Scael.It Ic verbose
84350621ScaelToggle verbose mode.
84450621ScaelIn verbose mode, all responses from
84550621Scaelthe
84650621Scael.Tn FTP
84750621Scaelserver are displayed to the user.
84850621ScaelIn addition,
84926050Sminshallif verbose is on, when a file transfer completes, statistics
85050621Scaelregarding the efficiency of the transfer are reported.
85150621ScaelBy default,
85226050Sminshallverbose is on.
85350621Scael.It Ic ? Op Ar command
85426050SminshallA synonym for help.
85550621Scael.El
85643083Scael.Pp
85719706SmckusickCommand arguments which have embedded spaces may be quoted with
85844954Scaelquote `"' marks.
85944954Scael.Sh ABORTING A FILE TRANSFER
86027895SkarelsTo abort a file transfer, use the terminal interrupt key
86126050Sminshall(usually Ctrl-C).
86226050SminshallSending transfers will be immediately halted.
86350621ScaelReceiving transfers will be halted by sending a ftp protocol
86450621Scael.Dv ABOR
86526050Sminshallcommand to the remote server, and discarding any further data received.
86626050SminshallThe speed at which this is accomplished depends upon the remote
86750621Scaelserver's support for
86850621Scael.Dv ABOR
86950621Scaelprocessing.
87050621ScaelIf the remote server does not support the
87150621Scael.Dv ABOR
87250621Scaelcommand, an
87344954Scael.Ql ftp>
87426050Sminshallprompt will not appear until the remote server has completed
87526050Sminshallsending the requested file.
87643083Scael.Pp
87726050SminshallThe terminal interrupt key sequence will be ignored when
87843083Scael.Nm ftp
87926050Sminshallhas completed any local processing and is awaiting a reply
88026050Sminshallfrom the remote server.
88126050SminshallA long delay in this mode may result from the ABOR processing described
88226050Sminshallabove, or from unexpected behavior by the remote server, including
88326050Sminshallviolations of the ftp protocol.
88426050SminshallIf the delay results from unexpected remote server behavior, the local
88543083Scael.Nm ftp
88626050Sminshallprogram must be killed by hand.
88744954Scael.Sh FILE NAMING CONVENTIONS
88826050SminshallFiles specified as arguments to
88943083Scael.Nm ftp
89019706Smckusickcommands are processed according to the following rules.
89150621Scael.Bl -enum
89250621Scael.It
89344954ScaelIf the file name
89444954Scael.Sq Fl
89544954Scaelis specified, the
89643083Scael.Ar stdin
89726050Sminshall(for reading) or
89843083Scael.Ar stdout
89919706Smckusick(for writing) is used.
90050621Scael.It
90144954ScaelIf the first character of the file name is
90244954Scael.Sq \&| ,
90344954Scaelthe
90419706Smckusickremainder of the argument is interpreted as a shell command.
90543083Scael.Nm Ftp
90643083Scaelthen forks a shell, using
90743083Scael.Xr popen 3
90826050Sminshallwith the argument supplied, and reads (writes) from the stdout
90950621Scael(stdin).
91050621ScaelIf the shell command includes spaces, the argument
91150621Scaelmust be quoted; e.g.
91250621Scael\*(Lq" ls -lt"\*(Rq.
91350621ScaelA particularly
91443083Scaeluseful example of this mechanism is: \*(Lqdir more\*(Rq.
91550621Scael.It
91643083ScaelFailing the above checks, if ``globbing'' is enabled,
91719706Smckusicklocal file names are expanded
91843083Scaelaccording to the rules used in the
91943083Scael.Xr csh  1  ;
92043083Scaelc.f. the
92143083Scael.Ic glob
92243083Scaelcommand.
92326050SminshallIf the
92443083Scael.Nm ftp
92544954Scaelcommand expects a single local file (.e.g.
92643083Scael.Ic put  ) ,
92726050Sminshallonly the first filename generated by the "globbing" operation is used.
92850621Scael.It
92926050SminshallFor
93043083Scael.Ic mget
93126050Sminshallcommands and
93243083Scael.Ic get
93326050Sminshallcommands with unspecified local file names, the local filename is
93426050Sminshallthe remote filename, which may be altered by a
93543083Scael.Ic case  ,
93643083Scael.Ic ntrans ,
93726050Sminshallor
93843083Scael.Ic nmap
93926050Sminshallsetting.
94026050SminshallThe resulting filename may then be altered if
94143083Scael.Ic runique
94226050Sminshallis on.
94350621Scael.It
94426050SminshallFor
94543083Scael.Ic mput
94626050Sminshallcommands and
94743083Scael.Ic put
94826050Sminshallcommands with unspecified remote file names, the remote filename is
94926050Sminshallthe local filename, which may be altered by a
95043083Scael.Ic ntrans
95126050Sminshallor
95243083Scael.Ic nmap
95326050Sminshallsetting.
95426050SminshallThe resulting filename may then be altered by the remote server if
95543083Scael.Ic sunique
95626050Sminshallis on.
95750621Scael.El
95844954Scael.Sh FILE TRANSFER PARAMETERS
95919706SmckusickThe FTP specification specifies many parameters which may
96050621Scaelaffect a file transfer.
96150621ScaelThe
96243083Scael.Ic type
96343083Scaelmay be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary),
96450621Scael\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for
96550621Scael.Tn PDP Ns -10's
96650621Scaeland
96750621Scael.Tn PDP Ns -20's
96850621Scaelmostly).
96943083Scael.Nm Ftp
97026050Sminshallsupports the ascii and image types of file transfer,
97143083Scaelplus local byte size 8 for
97243083Scael.Ic tenex
97343083Scaelmode transfers.
97443083Scael.Pp
97543083Scael.Nm Ftp
97626050Sminshallsupports only the default values for the remaining
97743083Scaelfile transfer parameters:
97843083Scael.Ic mode  ,
97943083Scael.Ic form ,
98026050Sminshalland
98143083Scael.Ic struct  .
98244954Scael.Sh THE .netrc FILE
98326050SminshallThe
98443083Scael.Pa .netrc
98543083Scaelfile contains login and initialization information
98626050Sminshallused by the auto-login process.
98726050SminshallIt resides in the user's home directory.
98826050SminshallThe following tokens are recognized; they may be separated by spaces,
98926050Sminshalltabs, or new-lines:
99050621Scael.Bl -tag -width password
99150621Scael.It Ic machine Ar name
99244954ScaelIdentify a remote machine
99344954Scael.Ar name .
99444954ScaelThe auto-login process searches the
99544954Scael.Pa .netrc
99644954Scaelfile for a
99743083Scael.Ic machine
99826491Sminshalltoken that matches the remote machine specified on the
99943083Scael.Nm ftp
100026050Sminshallcommand line or as an
100143083Scael.Ic open
100226050Sminshallcommand argument.
100344954ScaelOnce a match is made, the subsequent
100444954Scael.Pa .netrc
100544954Scaeltokens are processed,
100626050Sminshallstopping when the end of file is reached or another
100743083Scael.Ic machine
100836940Skarelsor a
100943083Scael.Ic default
101026050Sminshalltoken is encountered.
101150621Scael.It Ic default
101243083ScaelThis is the same as
101343083Scael.Ic machine
101443083Scael.Ar name
101543083Scaelexcept that
101643083Scael.Ic default
101736940Skarelsmatches any name.
101843083ScaelThere can be only one
101943083Scael.Ic default
102043083Scaeltoken, and it must be after all
102143083Scael.Ic machine
102243083Scaeltokens.
102336940SkarelsThis is normally used as:
102444954Scael.Pp
102543083Scael.Dl default login anonymous password user@site
102644954Scael.Pp
102743083Scaelthereby giving the user
102843083Scael.Ar automatic
102943083Scaelanonymous ftp login to
103043083Scaelmachines not specified in
103143083Scael.Pa .netrc .
103243083ScaelThis can be overridden
103343083Scaelby using the
103443083Scael.Fl n
103543083Scaelflag to disable auto-login.
103650621Scael.It Ic login Ar name
103726050SminshallIdentify a user on the remote machine.
103826050SminshallIf this token is present, the auto-login process will initiate
103944954Scaela login using the specified
104044954Scael.Ar name .
104150621Scael.It Ic password Ar string
104226050SminshallSupply a password.
104326050SminshallIf this token is present, the auto-login process will supply the
104426050Sminshallspecified string if the remote server requires a password as part
104526050Sminshallof the login process.
104643083ScaelNote that if this token is present in the
104743083Scael.Pa .netrc
104843083Scaelfile for any user other
104943083Scaelthan
105043083Scael.Ar anonymous  ,
105143083Scael.Nm ftp
105243083Scaelwill abort the auto-login process if the
105343083Scael.Pa .netrc
105443083Scaelis readable by
105526050Sminshallanyone besides the user.
105650697Scael.It Ic account Ar string
105726050SminshallSupply an additional account password.
105826050SminshallIf this token is present, the auto-login process will supply the
105926050Sminshallspecified string if the remote server requires an additional
106026050Sminshallaccount password, or the auto-login process will initiate an
106150621Scael.Dv ACCT
106250621Scaelcommand if it does not.
106350621Scael.It Ic macdef Ar name
106426050SminshallDefine a macro.
106526050SminshallThis token functions like the
106643083Scael.Nm ftp
106743083Scael.Ic macdef
106826050Sminshallcommand functions.
106926050SminshallA macro is defined with the specified name; its contents begin with the
107043083Scaelnext
107143083Scael.Pa .netrc
107243083Scaelline and continue until a null line (consecutive new-line
107326050Sminshallcharacters) is encountered.
107426050SminshallIf a macro named
107543083Scael.Ic init
107626050Sminshallis defined, it is automatically executed as the last step in the
107726050Sminshallauto-login process.
107850621Scael.El
107943083Scael.Sh ENVIRONMENT
108043083Scael.Nm Ftp
108144954Scaelutilizes the following environment variables.
108250621Scael.Bl -tag -width Fl
108350621Scael.It Ev HOME
108444954ScaelFor default location of a
108544954Scael.Pa .netrc
108644954Scaelfile, if one exists.
108750621Scael.It Ev SHELL
108844954ScaelFor default shell.
108950621Scael.El
109043083Scael.Sh SEE ALSO
109143083Scael.Xr ftpd 8
109243083Scael.Sh HISTORY
109350621ScaelThe
109450621Scael.Nm ftp
109550621Scaelcommand appeared in
109650621Scael.Bx 4.2 .
109743083Scael.Sh BUGS
109826050SminshallCorrect execution of many commands depends upon proper behavior
109926050Sminshallby the remote server.
110043083Scael.Pp
110127895SkarelsAn error in the treatment of carriage returns
110250621Scaelin the
110350621Scael.Bx 4.2
110450621Scaelascii-mode transfer code
110526050Sminshallhas been corrected.
110626050SminshallThis correction may result in incorrect transfers of binary files
110750621Scaelto and from
110850621Scael.Bx 4.2
110950621Scaelservers using the ascii type.
111026050SminshallAvoid this problem by using the binary image type.
1111