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