162009Sbostic.\" Copyright (c) 1985, 1989, 1990, 1993 262009Sbostic.\" The Regents of the University of California. All rights reserved. 319706Smckusick.\" 450621Scael.\" %sccs.include.redist.roff% 519706Smckusick.\" 6*67794Smckusick.\" @(#)ftp.1 8.3 (Berkeley) 10/09/94 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 30165227Smckusickis omitted, 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. 337*67794Smckusick.It Ic macdef 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). 578*67794Smckusick.It Ic passive 579*67794SmckusickToggle passive mode. If passive mode is turned on 580*67794Smckusick(default is off), the ftp client will 581*67794Smckusicksend a 582*67794Smckusick.Dv PASV 583*67794Smckusickcommand for all data connections instead of the usual 584*67794Smckusick.Dv PORT 585*67794Smckusickcommand. The 586*67794Smckusick.Dv PASV 587*67794Smckusickcommand requests that the remote server open a port for the data connection 588*67794Smckusickand return the address of that port. The remote server listens on that 589*67794Smckusickport and the client connects to it. When using the more traditional 590*67794Smckusick.Dv PORT 591*67794Smckusickcommand, the client listens on a port and sends that address to the remote 592*67794Smckusickserver, who connects back to it. Passive mode is useful when using 593*67794Smckusick.Nm ftp 594*67794Smckusickthrough a gateway router or host that controls the directionality of 595*67794Smckusicktraffic. 596*67794Smckusick(Note that though ftp servers are required to support the 597*67794Smckusick.Dv PASV 598*67794Smckusickcommand by RFC 1123, some do not.) 59950621Scael.It Ic prompt 60050621ScaelToggle interactive prompting. 60150621ScaelInteractive prompting 60219706Smckusickoccurs during multiple file transfers to allow the 60319707Smckusickuser to selectively retrieve or store files. 60443083ScaelIf prompting is turned off (default is on), any 60543083Scael.Ic mget 60643083Scaelor 60743083Scael.Ic mput 60843083Scaelwill transfer all files, and any 60943083Scael.Ic mdelete 61043083Scaelwill delete all files. 61150621Scael.It Ic proxy Ar ftp-command 61226050SminshallExecute an ftp command on a secondary control connection. 61326050SminshallThis command allows simultaneous connection to two remote ftp 61426050Sminshallservers for transferring files between the two servers. 61526050SminshallThe first 61643083Scael.Ic proxy 61726050Sminshallcommand should be an 61843083Scael.Ic open , 61926050Sminshallto establish the secondary control connection. 62026050SminshallEnter the command "proxy ?" to see other ftp commands executable on the 62126050Sminshallsecondary connection. 62227895SkarelsThe following commands behave differently when prefaced by 62343083Scael.Ic proxy : 62443083Scael.Ic open 62526050Sminshallwill not define new macros during the auto-login process, 62643083Scael.Ic close 62726050Sminshallwill not erase existing macro definitions, 62843083Scael.Ic get 62926050Sminshalland 63043083Scael.Ic mget 63126050Sminshalltransfer files from the host on the primary control connection 63226050Sminshallto the host on the secondary control connection, and 63343083Scael.Ic put , 63443083Scael.Ic mput , 63526050Sminshalland 63643083Scael.Ic append 63726050Sminshalltransfer files from the host on the secondary control connection 63826050Sminshallto the host on the primary control connection. 63926050SminshallThird party file transfers depend upon support of the ftp protocol 64050621Scael.Dv PASV 64150621Scaelcommand by the server on the secondary control connection. 64250621Scael.It Ic put Ar local-file Op Ar remote-file 64350621ScaelStore a local file on the remote machine. 64450621ScaelIf 64543083Scael.Ar remote-file 64619706Smckusickis left unspecified, the local file name is used 64726050Sminshallafter processing according to any 64843083Scael.Ic ntrans 64926050Sminshallor 65043083Scael.Ic nmap 65126050Sminshallsettings 65250621Scaelin naming the remote file. 65350621ScaelFile transfer uses the 65426050Sminshallcurrent settings for 65543083Scael.Ic type , 65643083Scael.Ic format , 65743083Scael.Ic mode , 65826050Sminshalland 65943083Scael.Ic structure . 66050621Scael.It Ic pwd 66119706SmckusickPrint the name of the current working directory on the remote 66219706Smckusickmachine. 66350621Scael.It Ic quit 66426085SlepreauA synonym for 66543083Scael.Ic bye . 66650621Scael.It Ic quote Ar arg1 arg2 ... 66750621ScaelThe arguments specified are sent, verbatim, to the remote 66850621Scael.Tn FTP 66926050Sminshallserver. 67050621Scael.It Ic recv Ar remote-file Op Ar local-file 67126050SminshallA synonym for get. 67250621Scael.It Ic reget Ar remote-file Op Ar local-file 67343083ScaelReget acts like get, except that if 67443083Scael.Ar local-file 67543083Scaelexists and is 67643083Scaelsmaller than 67743083Scael.Ar remote-file , 67843083Scael.Ar local-file 67943083Scaelis presumed to be 68043083Scaela partially transferred copy of 68143083Scael.Ar remote-file 68243083Scaeland the transfer 68350621Scaelis continued from the apparent point of failure. 68450621ScaelThis command 68537224Skarelsis useful when transferring very large files over networks that 68637224Skarelsare prone to dropping connections. 68750621Scael.It Ic remotehelp Op Ar command-name 68850621ScaelRequest help from the remote 68950621Scael.Tn FTP 69050621Scaelserver. 69150621ScaelIf a 69243083Scael.Ar command-name 69319706Smckusickis specified it is supplied to the server as well. 69450621Scael.It Ic remotestatus Op Ar file-name 69550621ScaelWith no arguments, show status of remote machine. 69650621ScaelIf 69743083Scael.Ar file-name 69843083Scaelis specified, show status of 69943083Scael.Ar file-name 70043083Scaelon remote machine. 70150621Scael.It Xo 70250621Scael.Ic rename 70343083Scael.Op Ar from 70443083Scael.Op Ar to 70550621Scael.Xc 70619706SmckusickRename the file 70743083Scael.Ar from 70826050Sminshallon the remote machine, to the file 70943083Scael.Ar to . 71050621Scael.It Ic reset 71126050SminshallClear reply queue. 71226050SminshallThis command re-synchronizes command/reply sequencing with the remote 71326050Sminshallftp server. 71436935SkarelsResynchronization may be necessary following a violation of the ftp protocol 71526050Sminshallby the remote server. 71650621Scael.It Ic restart Ar marker 71743083ScaelRestart the immediately following 71843083Scael.Ic get 71943083Scaelor 72043083Scael.Ic put 72143083Scaelat the 72243083Scaelindicated 72343083Scael.Ar marker . 72450621ScaelOn 72550621Scael.Ux 72650621Scaelsystems, marker is usually a byte 72737224Skarelsoffset into the file. 72850621Scael.It Ic rmdir Ar directory-name 72919706SmckusickDelete a directory on the remote machine. 73050621Scael.It Ic runique 73126050SminshallToggle storing of files on the local system with unique filenames. 73226050SminshallIf a file already exists with a name equal to the target 73326050Sminshalllocal filename for a 73443083Scael.Ic get 73526050Sminshallor 73643083Scael.Ic mget 73726491Sminshallcommand, a ".1" is appended to the name. 73826050SminshallIf the resulting name matches another existing file, 73926050Sminshalla ".2" is appended to the original name. 74026050SminshallIf this process continues up to ".99", an error 74126050Sminshallmessage is printed, and the transfer does not take place. 74226050SminshallThe generated unique filename will be reported. 74326050SminshallNote that 74443083Scael.Ic runique 74526050Sminshallwill not affect local files generated from a shell command 74626050Sminshall(see below). 74726050SminshallThe default value is off. 74850621Scael.It Ic send Ar local-file Op Ar remote-file 74926050SminshallA synonym for put. 75050621Scael.It Ic sendport 75150621ScaelToggle the use of 75250621Scael.Dv PORT 75350621Scaelcommands. 75450621ScaelBy default, 75543083Scael.Nm ftp 75650621Scaelwill attempt to use a 75750621Scael.Dv PORT 75850621Scaelcommand when establishing 75926050Sminshalla connection for each data transfer. 76050621ScaelThe use of 76150621Scael.Dv PORT 76250621Scaelcommands can prevent delays 76350621Scaelwhen performing multiple file transfers. 76450621ScaelIf the 76550621Scael.Dv PORT 76643083Scaelcommand fails, 76743083Scael.Nm ftp 76850621Scaelwill use the default data port. 76950621ScaelWhen the use of 77050621Scael.Dv PORT 77119706Smckusickcommands is disabled, no attempt will be made to use 77250621Scael.Dv PORT 77350621Scaelcommands for each data transfer. 77450621ScaelThis is useful 77550621Scaelfor certain 77650621Scael.Tn FTP 77750621Scaelimplementations which do ignore 77850621Scael.Dv PORT 77926050Sminshallcommands but, incorrectly, indicate they've been accepted. 78050621Scael.It Ic site Ar arg1 arg2 ... 78150621ScaelThe arguments specified are sent, verbatim, to the remote 78250621Scael.Tn FTP 78350621Scaelserver as a 78450621Scael.Dv SITE 78550621Scaelcommand. 78650621Scael.It Ic size Ar file-name 78743083ScaelReturn size of 78843083Scael.Ar file-name 78943083Scaelon remote machine. 79050621Scael.It Ic status 79119706SmckusickShow the current status of 79243083Scael.Nm ftp . 79350621Scael.It Ic struct Op Ar struct-name 79426050SminshallSet the file transfer 79543083Scael.Ar structure 79626050Sminshallto 79744954Scael.Ar struct-name . 79843083ScaelBy default \*(Lqstream\*(Rq structure is used. 79950621Scael.It Ic sunique 80026050SminshallToggle storing of files on remote machine under unique file names. 80150621ScaelRemote ftp server must support ftp protocol 80250621Scael.Dv STOU 80350621Scaelcommand for 80426050Sminshallsuccessful completion. 80526050SminshallThe remote server will report unique name. 80626050SminshallDefault value is off. 80750621Scael.It Ic system 80836935SkarelsShow the type of operating system running on the remote machine. 80950621Scael.It Ic tenex 81026050SminshallSet the file transfer type to that needed to 81150621Scaeltalk to 81250621Scael.Tn TENEX 81350621Scaelmachines. 81450621Scael.It Ic trace 81526050SminshallToggle packet tracing. 81650621Scael.It Ic type Op Ar type-name 81726050SminshallSet the file transfer 81843083Scael.Ic type 81926050Sminshallto 82043083Scael.Ar type-name . 82119706SmckusickIf no type is specified, the current type 82250621Scaelis printed. 82350621ScaelThe default type is network 82450621Scael.Tn ASCII . 82550621Scael.It Ic umask Op Ar newmask 82643083ScaelSet the default umask on the remote server to 82744954Scael.Ar newmask . 82843083ScaelIf 82944954Scael.Ar newmask 83065227Smckusickis omitted, the current umask is printed. 83150621Scael.It Xo 83250621Scael.Ic user Ar user-name 83343083Scael.Op Ar password 83443083Scael.Op Ar account 83550621Scael.Xc 83650621ScaelIdentify yourself to the remote 83750621Scael.Tn FTP 83850621Scaelserver. 83950621ScaelIf the 84044954Scael.Ar password 84144954Scaelis not specified and the server requires it, 84243083Scael.Nm ftp 84319706Smckusickwill prompt the user for it (after disabling local echo). 84444954ScaelIf an 84544954Scael.Ar account 84650621Scaelfield is not specified, and the 84750621Scael.Tn FTP 84850621Scaelserver 84926050Sminshallrequires it, the user will be prompted for it. 85044954ScaelIf an 85144954Scael.Ar account 85244954Scaelfield is specified, an account command will 85326050Sminshallbe relayed to the remote server after the login sequence 85426050Sminshallis completed if the remote server did not require it 85526050Sminshallfor logging in. 85626050SminshallUnless 85743083Scael.Nm ftp 85843083Scaelis invoked with \*(Lqauto-login\*(Rq disabled, this 85919706Smckusickprocess is done automatically on initial connection to 86050621Scaelthe 86150621Scael.Tn FTP 86250621Scaelserver. 86350621Scael.It Ic verbose 86450621ScaelToggle verbose mode. 86550621ScaelIn verbose mode, all responses from 86650621Scaelthe 86750621Scael.Tn FTP 86850621Scaelserver are displayed to the user. 86950621ScaelIn addition, 87026050Sminshallif verbose is on, when a file transfer completes, statistics 87150621Scaelregarding the efficiency of the transfer are reported. 87250621ScaelBy default, 87326050Sminshallverbose is on. 87450621Scael.It Ic ? Op Ar command 87526050SminshallA synonym for help. 87650621Scael.El 87743083Scael.Pp 87819706SmckusickCommand arguments which have embedded spaces may be quoted with 87944954Scaelquote `"' marks. 88044954Scael.Sh ABORTING A FILE TRANSFER 88127895SkarelsTo abort a file transfer, use the terminal interrupt key 88226050Sminshall(usually Ctrl-C). 88326050SminshallSending transfers will be immediately halted. 88450621ScaelReceiving transfers will be halted by sending a ftp protocol 88550621Scael.Dv ABOR 88626050Sminshallcommand to the remote server, and discarding any further data received. 88726050SminshallThe speed at which this is accomplished depends upon the remote 88850621Scaelserver's support for 88950621Scael.Dv ABOR 89050621Scaelprocessing. 89150621ScaelIf the remote server does not support the 89250621Scael.Dv ABOR 89350621Scaelcommand, an 89444954Scael.Ql ftp> 89526050Sminshallprompt will not appear until the remote server has completed 89626050Sminshallsending the requested file. 89743083Scael.Pp 89826050SminshallThe terminal interrupt key sequence will be ignored when 89943083Scael.Nm ftp 90026050Sminshallhas completed any local processing and is awaiting a reply 90126050Sminshallfrom the remote server. 90226050SminshallA long delay in this mode may result from the ABOR processing described 90326050Sminshallabove, or from unexpected behavior by the remote server, including 90426050Sminshallviolations of the ftp protocol. 90526050SminshallIf the delay results from unexpected remote server behavior, the local 90643083Scael.Nm ftp 90726050Sminshallprogram must be killed by hand. 90844954Scael.Sh FILE NAMING CONVENTIONS 90926050SminshallFiles specified as arguments to 91043083Scael.Nm ftp 91119706Smckusickcommands are processed according to the following rules. 91250621Scael.Bl -enum 91350621Scael.It 91444954ScaelIf the file name 91544954Scael.Sq Fl 91644954Scaelis specified, the 91743083Scael.Ar stdin 91826050Sminshall(for reading) or 91943083Scael.Ar stdout 92019706Smckusick(for writing) is used. 92150621Scael.It 92244954ScaelIf the first character of the file name is 92344954Scael.Sq \&| , 92444954Scaelthe 92519706Smckusickremainder of the argument is interpreted as a shell command. 92643083Scael.Nm Ftp 92743083Scaelthen forks a shell, using 92843083Scael.Xr popen 3 92926050Sminshallwith the argument supplied, and reads (writes) from the stdout 93050621Scael(stdin). 93150621ScaelIf the shell command includes spaces, the argument 93250621Scaelmust be quoted; e.g. 93350621Scael\*(Lq" ls -lt"\*(Rq. 93450621ScaelA particularly 93543083Scaeluseful example of this mechanism is: \*(Lqdir more\*(Rq. 93650621Scael.It 93743083ScaelFailing the above checks, if ``globbing'' is enabled, 93819706Smckusicklocal file names are expanded 93943083Scaelaccording to the rules used in the 94043083Scael.Xr csh 1 ; 94143083Scaelc.f. the 94243083Scael.Ic glob 94343083Scaelcommand. 94426050SminshallIf the 94543083Scael.Nm ftp 94644954Scaelcommand expects a single local file (.e.g. 94743083Scael.Ic put ) , 94826050Sminshallonly the first filename generated by the "globbing" operation is used. 94950621Scael.It 95026050SminshallFor 95143083Scael.Ic mget 95226050Sminshallcommands and 95343083Scael.Ic get 95426050Sminshallcommands with unspecified local file names, the local filename is 95526050Sminshallthe remote filename, which may be altered by a 95643083Scael.Ic case , 95743083Scael.Ic ntrans , 95826050Sminshallor 95943083Scael.Ic nmap 96026050Sminshallsetting. 96126050SminshallThe resulting filename may then be altered if 96243083Scael.Ic runique 96326050Sminshallis on. 96450621Scael.It 96526050SminshallFor 96643083Scael.Ic mput 96726050Sminshallcommands and 96843083Scael.Ic put 96926050Sminshallcommands with unspecified remote file names, the remote filename is 97026050Sminshallthe local filename, which may be altered by a 97143083Scael.Ic ntrans 97226050Sminshallor 97343083Scael.Ic nmap 97426050Sminshallsetting. 97526050SminshallThe resulting filename may then be altered by the remote server if 97643083Scael.Ic sunique 97726050Sminshallis on. 97850621Scael.El 97944954Scael.Sh FILE TRANSFER PARAMETERS 98019706SmckusickThe FTP specification specifies many parameters which may 98150621Scaelaffect a file transfer. 98250621ScaelThe 98343083Scael.Ic type 98443083Scaelmay be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary), 98550621Scael\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for 98650621Scael.Tn PDP Ns -10's 98750621Scaeland 98850621Scael.Tn PDP Ns -20's 98950621Scaelmostly). 99043083Scael.Nm Ftp 99126050Sminshallsupports the ascii and image types of file transfer, 99243083Scaelplus local byte size 8 for 99343083Scael.Ic tenex 99443083Scaelmode transfers. 99543083Scael.Pp 99643083Scael.Nm Ftp 99726050Sminshallsupports only the default values for the remaining 99843083Scaelfile transfer parameters: 99943083Scael.Ic mode , 100043083Scael.Ic form , 100126050Sminshalland 100243083Scael.Ic struct . 100344954Scael.Sh THE .netrc FILE 100426050SminshallThe 100543083Scael.Pa .netrc 100643083Scaelfile contains login and initialization information 100726050Sminshallused by the auto-login process. 100826050SminshallIt resides in the user's home directory. 100926050SminshallThe following tokens are recognized; they may be separated by spaces, 101026050Sminshalltabs, or new-lines: 101150621Scael.Bl -tag -width password 101250621Scael.It Ic machine Ar name 101344954ScaelIdentify a remote machine 101444954Scael.Ar name . 101544954ScaelThe auto-login process searches the 101644954Scael.Pa .netrc 101744954Scaelfile for a 101843083Scael.Ic machine 101926491Sminshalltoken that matches the remote machine specified on the 102043083Scael.Nm ftp 102126050Sminshallcommand line or as an 102243083Scael.Ic open 102326050Sminshallcommand argument. 102444954ScaelOnce a match is made, the subsequent 102544954Scael.Pa .netrc 102644954Scaeltokens are processed, 102726050Sminshallstopping when the end of file is reached or another 102843083Scael.Ic machine 102936940Skarelsor a 103043083Scael.Ic default 103126050Sminshalltoken is encountered. 103250621Scael.It Ic default 103343083ScaelThis is the same as 103443083Scael.Ic machine 103543083Scael.Ar name 103643083Scaelexcept that 103743083Scael.Ic default 103836940Skarelsmatches any name. 103943083ScaelThere can be only one 104043083Scael.Ic default 104143083Scaeltoken, and it must be after all 104243083Scael.Ic machine 104343083Scaeltokens. 104436940SkarelsThis is normally used as: 104544954Scael.Pp 104643083Scael.Dl default login anonymous password user@site 104744954Scael.Pp 104843083Scaelthereby giving the user 104943083Scael.Ar automatic 105043083Scaelanonymous ftp login to 105143083Scaelmachines not specified in 105243083Scael.Pa .netrc . 105343083ScaelThis can be overridden 105443083Scaelby using the 105543083Scael.Fl n 105643083Scaelflag to disable auto-login. 105750621Scael.It Ic login Ar name 105826050SminshallIdentify a user on the remote machine. 105926050SminshallIf this token is present, the auto-login process will initiate 106044954Scaela login using the specified 106144954Scael.Ar name . 106250621Scael.It Ic password Ar string 106326050SminshallSupply a password. 106426050SminshallIf this token is present, the auto-login process will supply the 106526050Sminshallspecified string if the remote server requires a password as part 106626050Sminshallof the login process. 106743083ScaelNote that if this token is present in the 106843083Scael.Pa .netrc 106943083Scaelfile for any user other 107043083Scaelthan 107143083Scael.Ar anonymous , 107243083Scael.Nm ftp 107343083Scaelwill abort the auto-login process if the 107443083Scael.Pa .netrc 107543083Scaelis readable by 107626050Sminshallanyone besides the user. 107750697Scael.It Ic account Ar string 107826050SminshallSupply an additional account password. 107926050SminshallIf this token is present, the auto-login process will supply the 108026050Sminshallspecified string if the remote server requires an additional 108126050Sminshallaccount password, or the auto-login process will initiate an 108250621Scael.Dv ACCT 108350621Scaelcommand if it does not. 108450621Scael.It Ic macdef Ar name 108526050SminshallDefine a macro. 108626050SminshallThis token functions like the 108743083Scael.Nm ftp 108843083Scael.Ic macdef 108926050Sminshallcommand functions. 109026050SminshallA macro is defined with the specified name; its contents begin with the 109143083Scaelnext 109243083Scael.Pa .netrc 109343083Scaelline and continue until a null line (consecutive new-line 109426050Sminshallcharacters) is encountered. 109526050SminshallIf a macro named 109643083Scael.Ic init 109726050Sminshallis defined, it is automatically executed as the last step in the 109826050Sminshallauto-login process. 109950621Scael.El 110043083Scael.Sh ENVIRONMENT 110143083Scael.Nm Ftp 110244954Scaelutilizes the following environment variables. 110350621Scael.Bl -tag -width Fl 110450621Scael.It Ev HOME 110544954ScaelFor default location of a 110644954Scael.Pa .netrc 110744954Scaelfile, if one exists. 110850621Scael.It Ev SHELL 110944954ScaelFor default shell. 111050621Scael.El 111143083Scael.Sh SEE ALSO 111243083Scael.Xr ftpd 8 111343083Scael.Sh HISTORY 111450621ScaelThe 111550621Scael.Nm ftp 111650621Scaelcommand appeared in 111750621Scael.Bx 4.2 . 111843083Scael.Sh BUGS 111926050SminshallCorrect execution of many commands depends upon proper behavior 112026050Sminshallby the remote server. 112143083Scael.Pp 112227895SkarelsAn error in the treatment of carriage returns 112350621Scaelin the 112450621Scael.Bx 4.2 112550621Scaelascii-mode transfer code 112626050Sminshallhas been corrected. 112726050SminshallThis correction may result in incorrect transfers of binary files 112850621Scaelto and from 112950621Scael.Bx 4.2 113050621Scaelservers using the ascii type. 113126050SminshallAvoid this problem by using the binary image type. 1132