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.3 (Berkeley) 10/09/94 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 macdef 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 passive 579Toggle passive mode. If passive mode is turned on 580(default is off), the ftp client will 581send a 582.Dv PASV 583command for all data connections instead of the usual 584.Dv PORT 585command. The 586.Dv PASV 587command requests that the remote server open a port for the data connection 588and return the address of that port. The remote server listens on that 589port and the client connects to it. When using the more traditional 590.Dv PORT 591command, the client listens on a port and sends that address to the remote 592server, who connects back to it. Passive mode is useful when using 593.Nm ftp 594through a gateway router or host that controls the directionality of 595traffic. 596(Note that though ftp servers are required to support the 597.Dv PASV 598command by RFC 1123, some do not.) 599.It Ic prompt 600Toggle interactive prompting. 601Interactive prompting 602occurs during multiple file transfers to allow the 603user to selectively retrieve or store files. 604If prompting is turned off (default is on), any 605.Ic mget 606or 607.Ic mput 608will transfer all files, and any 609.Ic mdelete 610will delete all files. 611.It Ic proxy Ar ftp-command 612Execute an ftp command on a secondary control connection. 613This command allows simultaneous connection to two remote ftp 614servers for transferring files between the two servers. 615The first 616.Ic proxy 617command should be an 618.Ic open , 619to establish the secondary control connection. 620Enter the command "proxy ?" to see other ftp commands executable on the 621secondary connection. 622The following commands behave differently when prefaced by 623.Ic proxy : 624.Ic open 625will not define new macros during the auto-login process, 626.Ic close 627will not erase existing macro definitions, 628.Ic get 629and 630.Ic mget 631transfer files from the host on the primary control connection 632to the host on the secondary control connection, and 633.Ic put , 634.Ic mput , 635and 636.Ic append 637transfer files from the host on the secondary control connection 638to the host on the primary control connection. 639Third party file transfers depend upon support of the ftp protocol 640.Dv PASV 641command by the server on the secondary control connection. 642.It Ic put Ar local-file Op Ar remote-file 643Store a local file on the remote machine. 644If 645.Ar remote-file 646is left unspecified, the local file name is used 647after processing according to any 648.Ic ntrans 649or 650.Ic nmap 651settings 652in naming the remote file. 653File transfer uses the 654current settings for 655.Ic type , 656.Ic format , 657.Ic mode , 658and 659.Ic structure . 660.It Ic pwd 661Print the name of the current working directory on the remote 662machine. 663.It Ic quit 664A synonym for 665.Ic bye . 666.It Ic quote Ar arg1 arg2 ... 667The arguments specified are sent, verbatim, to the remote 668.Tn FTP 669server. 670.It Ic recv Ar remote-file Op Ar local-file 671A synonym for get. 672.It Ic reget Ar remote-file Op Ar local-file 673Reget acts like get, except that if 674.Ar local-file 675exists and is 676smaller than 677.Ar remote-file , 678.Ar local-file 679is presumed to be 680a partially transferred copy of 681.Ar remote-file 682and the transfer 683is continued from the apparent point of failure. 684This command 685is useful when transferring very large files over networks that 686are prone to dropping connections. 687.It Ic remotehelp Op Ar command-name 688Request help from the remote 689.Tn FTP 690server. 691If a 692.Ar command-name 693is specified it is supplied to the server as well. 694.It Ic remotestatus Op Ar file-name 695With no arguments, show status of remote machine. 696If 697.Ar file-name 698is specified, show status of 699.Ar file-name 700on remote machine. 701.It Xo 702.Ic rename 703.Op Ar from 704.Op Ar to 705.Xc 706Rename the file 707.Ar from 708on the remote machine, to the file 709.Ar to . 710.It Ic reset 711Clear reply queue. 712This command re-synchronizes command/reply sequencing with the remote 713ftp server. 714Resynchronization may be necessary following a violation of the ftp protocol 715by the remote server. 716.It Ic restart Ar marker 717Restart the immediately following 718.Ic get 719or 720.Ic put 721at the 722indicated 723.Ar marker . 724On 725.Ux 726systems, marker is usually a byte 727offset into the file. 728.It Ic rmdir Ar directory-name 729Delete a directory on the remote machine. 730.It Ic runique 731Toggle storing of files on the local system with unique filenames. 732If a file already exists with a name equal to the target 733local filename for a 734.Ic get 735or 736.Ic mget 737command, a ".1" is appended to the name. 738If the resulting name matches another existing file, 739a ".2" is appended to the original name. 740If this process continues up to ".99", an error 741message is printed, and the transfer does not take place. 742The generated unique filename will be reported. 743Note that 744.Ic runique 745will not affect local files generated from a shell command 746(see below). 747The default value is off. 748.It Ic send Ar local-file Op Ar remote-file 749A synonym for put. 750.It Ic sendport 751Toggle the use of 752.Dv PORT 753commands. 754By default, 755.Nm ftp 756will attempt to use a 757.Dv PORT 758command when establishing 759a connection for each data transfer. 760The use of 761.Dv PORT 762commands can prevent delays 763when performing multiple file transfers. 764If the 765.Dv PORT 766command fails, 767.Nm ftp 768will use the default data port. 769When the use of 770.Dv PORT 771commands is disabled, no attempt will be made to use 772.Dv PORT 773commands for each data transfer. 774This is useful 775for certain 776.Tn FTP 777implementations which do ignore 778.Dv PORT 779commands but, incorrectly, indicate they've been accepted. 780.It Ic site Ar arg1 arg2 ... 781The arguments specified are sent, verbatim, to the remote 782.Tn FTP 783server as a 784.Dv SITE 785command. 786.It Ic size Ar file-name 787Return size of 788.Ar file-name 789on remote machine. 790.It Ic status 791Show the current status of 792.Nm ftp . 793.It Ic struct Op Ar struct-name 794Set the file transfer 795.Ar structure 796to 797.Ar struct-name . 798By default \*(Lqstream\*(Rq structure is used. 799.It Ic sunique 800Toggle storing of files on remote machine under unique file names. 801Remote ftp server must support ftp protocol 802.Dv STOU 803command for 804successful completion. 805The remote server will report unique name. 806Default value is off. 807.It Ic system 808Show the type of operating system running on the remote machine. 809.It Ic tenex 810Set the file transfer type to that needed to 811talk to 812.Tn TENEX 813machines. 814.It Ic trace 815Toggle packet tracing. 816.It Ic type Op Ar type-name 817Set the file transfer 818.Ic type 819to 820.Ar type-name . 821If no type is specified, the current type 822is printed. 823The default type is network 824.Tn ASCII . 825.It Ic umask Op Ar newmask 826Set the default umask on the remote server to 827.Ar newmask . 828If 829.Ar newmask 830is omitted, the current umask is printed. 831.It Xo 832.Ic user Ar user-name 833.Op Ar password 834.Op Ar account 835.Xc 836Identify yourself to the remote 837.Tn FTP 838server. 839If the 840.Ar password 841is not specified and the server requires it, 842.Nm ftp 843will prompt the user for it (after disabling local echo). 844If an 845.Ar account 846field is not specified, and the 847.Tn FTP 848server 849requires it, the user will be prompted for it. 850If an 851.Ar account 852field is specified, an account command will 853be relayed to the remote server after the login sequence 854is completed if the remote server did not require it 855for logging in. 856Unless 857.Nm ftp 858is invoked with \*(Lqauto-login\*(Rq disabled, this 859process is done automatically on initial connection to 860the 861.Tn FTP 862server. 863.It Ic verbose 864Toggle verbose mode. 865In verbose mode, all responses from 866the 867.Tn FTP 868server are displayed to the user. 869In addition, 870if verbose is on, when a file transfer completes, statistics 871regarding the efficiency of the transfer are reported. 872By default, 873verbose is on. 874.It Ic ? Op Ar command 875A synonym for help. 876.El 877.Pp 878Command arguments which have embedded spaces may be quoted with 879quote `"' marks. 880.Sh ABORTING A FILE TRANSFER 881To abort a file transfer, use the terminal interrupt key 882(usually Ctrl-C). 883Sending transfers will be immediately halted. 884Receiving transfers will be halted by sending a ftp protocol 885.Dv ABOR 886command to the remote server, and discarding any further data received. 887The speed at which this is accomplished depends upon the remote 888server's support for 889.Dv ABOR 890processing. 891If the remote server does not support the 892.Dv ABOR 893command, an 894.Ql ftp> 895prompt will not appear until the remote server has completed 896sending the requested file. 897.Pp 898The terminal interrupt key sequence will be ignored when 899.Nm ftp 900has completed any local processing and is awaiting a reply 901from the remote server. 902A long delay in this mode may result from the ABOR processing described 903above, or from unexpected behavior by the remote server, including 904violations of the ftp protocol. 905If the delay results from unexpected remote server behavior, the local 906.Nm ftp 907program must be killed by hand. 908.Sh FILE NAMING CONVENTIONS 909Files specified as arguments to 910.Nm ftp 911commands are processed according to the following rules. 912.Bl -enum 913.It 914If the file name 915.Sq Fl 916is specified, the 917.Ar stdin 918(for reading) or 919.Ar stdout 920(for writing) is used. 921.It 922If the first character of the file name is 923.Sq \&| , 924the 925remainder of the argument is interpreted as a shell command. 926.Nm Ftp 927then forks a shell, using 928.Xr popen 3 929with the argument supplied, and reads (writes) from the stdout 930(stdin). 931If the shell command includes spaces, the argument 932must be quoted; e.g. 933\*(Lq" ls -lt"\*(Rq. 934A particularly 935useful example of this mechanism is: \*(Lqdir more\*(Rq. 936.It 937Failing the above checks, if ``globbing'' is enabled, 938local file names are expanded 939according to the rules used in the 940.Xr csh 1 ; 941c.f. the 942.Ic glob 943command. 944If the 945.Nm ftp 946command expects a single local file (.e.g. 947.Ic put ) , 948only the first filename generated by the "globbing" operation is used. 949.It 950For 951.Ic mget 952commands and 953.Ic get 954commands with unspecified local file names, the local filename is 955the remote filename, which may be altered by a 956.Ic case , 957.Ic ntrans , 958or 959.Ic nmap 960setting. 961The resulting filename may then be altered if 962.Ic runique 963is on. 964.It 965For 966.Ic mput 967commands and 968.Ic put 969commands with unspecified remote file names, the remote filename is 970the local filename, which may be altered by a 971.Ic ntrans 972or 973.Ic nmap 974setting. 975The resulting filename may then be altered by the remote server if 976.Ic sunique 977is on. 978.El 979.Sh FILE TRANSFER PARAMETERS 980The FTP specification specifies many parameters which may 981affect a file transfer. 982The 983.Ic type 984may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary), 985\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for 986.Tn PDP Ns -10's 987and 988.Tn PDP Ns -20's 989mostly). 990.Nm Ftp 991supports the ascii and image types of file transfer, 992plus local byte size 8 for 993.Ic tenex 994mode transfers. 995.Pp 996.Nm Ftp 997supports only the default values for the remaining 998file transfer parameters: 999.Ic mode , 1000.Ic form , 1001and 1002.Ic struct . 1003.Sh THE .netrc FILE 1004The 1005.Pa .netrc 1006file contains login and initialization information 1007used by the auto-login process. 1008It resides in the user's home directory. 1009The following tokens are recognized; they may be separated by spaces, 1010tabs, or new-lines: 1011.Bl -tag -width password 1012.It Ic machine Ar name 1013Identify a remote machine 1014.Ar name . 1015The auto-login process searches the 1016.Pa .netrc 1017file for a 1018.Ic machine 1019token that matches the remote machine specified on the 1020.Nm ftp 1021command line or as an 1022.Ic open 1023command argument. 1024Once a match is made, the subsequent 1025.Pa .netrc 1026tokens are processed, 1027stopping when the end of file is reached or another 1028.Ic machine 1029or a 1030.Ic default 1031token is encountered. 1032.It Ic default 1033This is the same as 1034.Ic machine 1035.Ar name 1036except that 1037.Ic default 1038matches any name. 1039There can be only one 1040.Ic default 1041token, and it must be after all 1042.Ic machine 1043tokens. 1044This is normally used as: 1045.Pp 1046.Dl default login anonymous password user@site 1047.Pp 1048thereby giving the user 1049.Ar automatic 1050anonymous ftp login to 1051machines not specified in 1052.Pa .netrc . 1053This can be overridden 1054by using the 1055.Fl n 1056flag to disable auto-login. 1057.It Ic login Ar name 1058Identify a user on the remote machine. 1059If this token is present, the auto-login process will initiate 1060a login using the specified 1061.Ar name . 1062.It Ic password Ar string 1063Supply a password. 1064If this token is present, the auto-login process will supply the 1065specified string if the remote server requires a password as part 1066of the login process. 1067Note that if this token is present in the 1068.Pa .netrc 1069file for any user other 1070than 1071.Ar anonymous , 1072.Nm ftp 1073will abort the auto-login process if the 1074.Pa .netrc 1075is readable by 1076anyone besides the user. 1077.It Ic account Ar string 1078Supply an additional account password. 1079If this token is present, the auto-login process will supply the 1080specified string if the remote server requires an additional 1081account password, or the auto-login process will initiate an 1082.Dv ACCT 1083command if it does not. 1084.It Ic macdef Ar name 1085Define a macro. 1086This token functions like the 1087.Nm ftp 1088.Ic macdef 1089command functions. 1090A macro is defined with the specified name; its contents begin with the 1091next 1092.Pa .netrc 1093line and continue until a null line (consecutive new-line 1094characters) is encountered. 1095If a macro named 1096.Ic init 1097is defined, it is automatically executed as the last step in the 1098auto-login process. 1099.El 1100.Sh ENVIRONMENT 1101.Nm Ftp 1102utilizes the following environment variables. 1103.Bl -tag -width Fl 1104.It Ev HOME 1105For default location of a 1106.Pa .netrc 1107file, if one exists. 1108.It Ev SHELL 1109For default shell. 1110.El 1111.Sh SEE ALSO 1112.Xr ftpd 8 1113.Sh HISTORY 1114The 1115.Nm ftp 1116command appeared in 1117.Bx 4.2 . 1118.Sh BUGS 1119Correct execution of many commands depends upon proper behavior 1120by the remote server. 1121.Pp 1122An error in the treatment of carriage returns 1123in the 1124.Bx 4.2 1125ascii-mode transfer code 1126has been corrected. 1127This correction may result in incorrect transfers of binary files 1128to and from 1129.Bx 4.2 1130servers using the ascii type. 1131Avoid this problem by using the binary image type. 1132