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