1.\" $OpenBSD: ftp.1,v 1.33 2001/03/09 16:59:38 millert Exp $ 2.\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $ 3.\" 4.\" Copyright (c) 1985, 1989, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 36.\" 37.Dd August 18, 1997 38.Dt FTP 1 39.Os 40.Sh NAME 41.Nm ftp 42.Nd 43.Tn ARPANET 44file transfer program 45.Sh SYNOPSIS 46.Nm ftp 47.Op Fl AVadegimnptv 48.Op Fl o Ar output 49.Op Fl P Ar port 50.Op Fl r Ar seconds 51.Op Ar host Op Ar port 52.Nm ftp 53ftp://[\fIuser\fR:\fIpassword\fR@]\fIhost\fR[:\fIport\fR]/\fIfile\fR[/] 54.Nm ftp 55http://\fIhost\fR[:\fIport\fR]/\fIfile\fR 56.Nm ftp 57\fIhost\fR:[/\fIpath\fR/]\fIfile\fR[/] 58.Sh DESCRIPTION 59.Nm 60is the user interface to the 61.Tn ARPANET 62standard File Transfer Protocol. 63The program allows a user to transfer files to and from a 64remote network site. 65.Pp 66The latter three usage formats will fetch a file using either the 67HTTP or FTP protocols into the current directory. 68This is ideal for scripts. 69Refer to 70.Sx AUTO-FETCHING FILES 71below for more information. 72.Pp 73The options are as follows: 74.Bl -tag -width Ds 75.It Fl A 76Force active mode ftp. 77By default, 78.Nm 79will try to use passive mode ftp and fall back to active mode 80if passive is not supported by the server. 81This option causes 82.Nm 83to always use an active connection. 84It is only useful for connecting 85to very old servers that do not implement passive mode properly. 86.It Fl a 87Causes 88.Nm 89to bypass the normal login procedure and use an anonymous login instead. 90.It Fl d 91Enables debugging. 92.It Fl e 93Disables command line editing. 94Useful for Emacs ange-ftp. 95.It Fl g 96Disables file name globbing. 97.It Fl i 98Turns off interactive prompting during 99multiple file transfers. 100.It Fl m 101Causes 102.Nm 103to always display the progress meter in cases where it would not do 104so by default. 105.It Fl n 106Restrains 107.Nm 108from attempting 109.Dq auto-login 110upon initial connection. 111If auto-login is enabled, 112.Nm 113will check the 114.Pa .netrc 115(see below) file in the user's home directory for an entry describing 116an account on the remote machine. 117If no entry exists, 118.Nm 119will prompt for the remote machine login name (default is the user 120identity on the local machine), and, if necessary, prompt for a password 121and an account with which to login. 122.It Fl o Ar output 123When fetching a single file or url, save the contents in 124.Ar output . 125To make the contents go to stdout, 126use 127.Dq - 128for 129.Ar output . 130.It Fl p 131Enable passive mode operation for use behind connection filtering firewalls. 132This option has been deprecated as 133.Nm 134now tries to use passive mode by default, falling back to active mode 135if the server does not support passive connections. 136.It Fl P Ar port 137Sets the port number to 138.Ar port . 139.It Fl r Ar number 140Retry to connect if failed, pausing for 141.Ar number 142of seconds. 143.It Fl t 144Enables packet tracing. 145.It Fl v 146Enable verbose mode. 147This is the default if input is from a terminal. 148Forces 149.Nm 150to show all responses from the remote server, as well 151as report on data transfer statistics. 152.It Fl V 153Disable verbose mode, overriding the default of enabled when input 154is from a terminal. 155.El 156.Pp 157The client host with which 158.Nm 159is to communicate may be specified on the command line. 160If this is done, 161.Nm 162will immediately attempt to establish a connection to an 163.Tn FTP 164server on that host; otherwise, 165.Nm 166will enter its command interpreter and await instructions 167from the user. 168When 169.Nm 170is awaiting commands the prompt 171.Dq ftp> 172is provided to the user. 173The following commands are recognized 174by 175.Nm ftp : 176.Bl -tag -width Fl 177.It Ic \&! Op Ar command Op Ar args 178Invoke an interactive shell on the local machine. 179If there are arguments, the first is taken to be a command to execute 180directly, with the rest of the arguments as its arguments. 181.It Ic \&$ Ar macro-name Op Ar args 182Execute the macro 183.Ar macro-name 184that was defined with the 185.Ic macdef 186command. 187Arguments are passed to the macro unglobbed. 188.It Ic account Op Ar passwd 189Supply a supplemental password required by a remote system for access 190to resources once a login has been successfully completed. 191If no argument is included, the user will be prompted for an account 192password in a non-echoing input mode. 193.It Ic append Ar local-file Op Ar remote-file 194Append a local file to a file on the remote machine. 195If 196.Ar remote-file 197is left unspecified, the local file name is used in naming the 198remote file after being altered by any 199.Ic ntrans 200or 201.Ic nmap 202setting. 203File transfer uses the current settings for 204.Ic type , 205.Ic format , 206.Ic mode , 207and 208.Ic structure . 209.It Ic ascii 210Set the file transfer 211.Ic type 212to network 213.Tn ASCII . 214This is the default type. 215.It Ic bell 216Arrange that a bell be sounded after each file transfer 217command is completed. 218.It Ic binary 219Set the file transfer 220.Ic type 221to support binary image transfer. 222.It Ic bye 223Terminate the 224.Tn FTP 225session with the remote server 226and exit 227.Nm ftp . 228An end-of-file will also terminate the session and exit. 229.It Ic case 230Toggle remote computer file name case mapping during 231.Ic mget 232commands. 233When 234.Ic case 235is on (default is off), remote computer file names with all letters in 236upper case are written in the local directory with the letters mapped 237to lower case. 238.It Ic \&cd Ar remote-directory 239Change the working directory on the remote machine 240to 241.Ar remote-directory . 242.It Ic cdup 243Change the remote machine working directory to the parent of the 244current remote machine working directory. 245.It Ic chmod Ar mode file-name 246Change the permission modes of the file 247.Ar file-name 248on the remote 249system to 250.Ar mode . 251.It Ic close 252Terminate the 253.Tn FTP 254session with the remote server and 255return to the command interpreter. 256Any defined macros are erased. 257.It Ic \&cr 258Toggle carriage return stripping during 259ASCII type file retrieval. 260Records are denoted by a carriage return/linefeed sequence 261during ASCII type file transfer. 262When 263.Ic \&cr 264is on (the default), carriage returns are stripped from this 265sequence to conform with the 266.Ux 267single linefeed record 268delimiter. 269Records on 270.Pf non\- Ns Ux 271remote systems may contain single linefeeds; 272when an ASCII type transfer is made, these linefeeds may be 273distinguished from a record delimiter only when 274.Ic \&cr 275is off. 276.It Ic delete Ar remote-file 277Delete the file 278.Ar remote-file 279on the remote machine. 280.It Ic debug Op Ar debug-value 281Toggle debugging mode. 282If an optional 283.Ar debug-value 284is specified it is used to set the debugging level. 285When debugging is on, 286.Nm 287prints each command sent to the remote machine, 288preceded by the string 289.Ql \-\-> . 290.It Ic dir Op Ar remote-directory Op Ar local-file 291A synonym for 292.Ic ls . 293.It Ic disconnect 294A synonym for 295.Ic close . 296.It Ic edit 297Toggle command line editing, and context sensitive command and file 298completion. 299This is automatically enabled if input is from a terminal, and 300disabled otherwise. 301.It Ic epsv4 302Toggle use of EPSV/EPRT command on IPv4 connection. 303.It Ic exit 304A synonym for 305.Ic bye . 306.It Ic ftp Ar host Op Ar port 307A synonym for 308.Ic open . 309.It Ic form Ar format 310Set the file transfer 311.Ic form 312to 313.Ar format . 314The default format is \*(Lqfile\*(Rq. 315.It Ic get Ar remote-file Op Ar local-file 316Retrieve the 317.Ar remote-file 318and store it on the local machine. 319If the local 320file name is not specified, it is given the same 321name it has on the remote machine, subject to 322alteration by the current 323.Ic case , 324.Ic ntrans , 325and 326.Ic nmap 327settings. 328The current settings for 329.Ic type , 330.Ic form , 331.Ic mode , 332and 333.Ic structure 334are used while transferring the file. 335.It Ic gate Op Ar host Op Ar port 336Toggle gate-ftp mode. 337This will not be permitted if the gate-ftp server hasn't been set 338(either explicitly by the user, or from the 339.Ev FTPSERVER 340environment variable). 341If 342.Ar host 343is given, 344then gate-ftp mode will be enabled, and the gate-ftp server will be set to 345.Ar host . 346If 347.Ar port 348is also given, that will be used as the port to connect to on the 349gate-ftp server. 350.It Ic glob 351Toggle filename expansion for 352.Ic mdelete , 353.Ic mget 354and 355.Ic mput . 356If globbing is turned off with 357.Ic glob , 358the file name arguments 359are taken literally and not expanded. 360Globbing for 361.Ic mput 362is done as in 363.Xr csh 1 . 364For 365.Ic mdelete 366and 367.Ic mget , 368each remote file name is expanded 369separately on the remote machine and the lists are not merged. 370Expansion of a directory name is likely to be 371different from expansion of the name of an ordinary file: 372the exact result depends on the foreign operating system and ftp server, 373and can be previewed by doing 374.Dq mls remote-files \- . 375Note: 376.Ic mget 377and 378.Ic mput 379are not meant to transfer 380entire directory subtrees of files. 381That can be done by 382transferring a 383.Xr tar 1 384archive of the subtree (in binary mode). 385.It Ic hash Op Ar size 386Toggle hash mark 387.Pq Ql # 388printing for each data block transferred. 389The size of a data block defaults to 1024 bytes. 390This can be changed by specifying 391.Ar size 392in bytes. 393.It Ic help Op Ar command 394Print an informative message about the meaning of 395.Ar command . 396If no argument is given, 397.Nm 398prints a list of the known commands. 399.It Ic idle Op Ar seconds 400Set the inactivity timer on the remote server to 401.Ar seconds 402seconds. 403If 404.Ar seconds 405is omitted, the current inactivity timer is printed. 406.It Ic lcd Op Ar directory 407Change the working directory on the local machine. 408If 409no 410.Ar directory 411is specified, the user's home directory is used. 412.It Ic less Ar file 413A synonym for 414.Ic page . 415.It Ic lpwd 416Print the working directory on the local machine. 417.It Ic \&ls Op Ar remote-directory Op Ar local-file 418Print a listing of the contents of a 419directory on the remote machine. 420The listing includes any system-dependent information that the server 421chooses to include; for example, most 422.Ux 423systems will produce 424output from the command 425.Ql ls \-l . 426If 427.Ar remote-directory 428is left unspecified, the current working directory is used. 429If interactive prompting is on, 430.Nm 431will prompt the user to verify that the last argument is indeed the 432target local file for receiving 433.Ic ls 434output. 435If no local file is specified, or if 436.Ar local-file 437is 438.Dq - , 439the output is sent to the terminal. 440.It Ic macdef Ar macro-name 441Define a macro. 442Subsequent lines are stored as the macro 443.Ar macro-name ; 444a null line (consecutive newline characters 445in a file or 446carriage returns from the terminal) terminates macro input mode. 447There is a limit of 16 macros and 4096 total characters in all 448defined macros. 449Macros remain defined until a 450.Ic close 451command is executed. 452The macro processor interprets 453.Ql $ 454and 455.Ql \e 456as special characters. 457A 458.Ql $ 459followed by a number (or numbers) is replaced by the 460corresponding argument on the macro invocation command line. 461A 462.Ql $ 463followed by an 464.Sq i 465tells the macro processor that the 466executing macro is to be looped. 467On the first pass 468.Ql $i 469is 470replaced by the first argument on the macro invocation command line, 471on the second pass it is replaced by the second argument, and so on. 472A 473.Ql \e 474followed by any character is replaced by that character. 475Use the 476.Ql \e 477to prevent special treatment of the 478.Ql $ . 479.It Ic mdelete Op Ar remote-files 480Delete the 481.Ar remote-files 482on the remote machine. 483.It Ic mdir Ar remote-files local-file 484A synonym for 485.Ic mls . 486.It Ic mget Ar remote-files 487Expand the 488.Ar remote-files 489on the remote machine 490and do a 491.Ic get 492for each file name thus produced. 493See 494.Ic glob 495for details on the filename expansion. 496Resulting file names will then be processed according to 497.Ic case , 498.Ic ntrans , 499and 500.Ic nmap 501settings. 502Files are transferred into the local working directory, 503which can be changed with 504.Ql lcd directory ; 505new local directories can be created with 506.Ql "\&! mkdir directory" . 507.It Ic mkdir Ar directory-name 508Make a directory on the remote machine. 509.It Ic mls Ar remote-files local-file 510Like 511.Ic ls , 512except multiple remote files may be specified, 513and the 514.Ar local-file 515must be specified. 516If interactive prompting is on, 517.Nm 518will prompt the user to verify that the last argument is indeed the 519target local file for receiving 520.Ic mls 521output. 522.It Ic mode Op Ar mode-name 523Set the file transfer 524.Ic mode 525to 526.Ar mode-name . 527The default mode is \*(Lqstream\*(Rq mode. 528.It Ic modtime Ar file-name 529Show the last modification time of the file on the remote machine. 530.It Ic more Ar file 531A synonym for 532.Ic page . 533.It Ic mput Ar local-files 534Expand wild cards in the list of local files given as arguments 535and do a 536.Ic put 537for each file in the resulting list. 538See 539.Ic glob 540for details of filename expansion. 541Resulting file names will then be processed according to 542.Ic ntrans 543and 544.Ic nmap 545settings. 546.It Ic msend Ar local-files 547A synonym for 548.Ic mput . 549.It Ic newer Ar file-name 550Get the file only if the modification time of the remote file is more 551recent than the file on the current system. 552If the file does not 553exist on the current system, the remote file is considered 554.Ic newer . 555Otherwise, this command is identical to 556.Ar get . 557.It Ic nlist Op Ar remote-directory Op Ar local-file 558Print a list of the files in a 559directory on the remote machine. 560If 561.Ar remote-directory 562is left unspecified, the current working directory is used. 563If interactive prompting is on, 564.Nm 565will prompt the user to verify that the last argument is indeed the 566target local file for receiving 567.Ic nlist 568output. 569If no local file is specified, or if 570.Ar local-file 571is 572.Dq - , 573the output is sent to the terminal. Note that on some servers, the 574.Ic nlist 575command will only return information on normal files (not directories 576or special files). 577.It Ic nmap Op Ar inpattern outpattern 578Set or unset the filename mapping mechanism. 579If no arguments are specified, the filename mapping mechanism is unset. 580If arguments are specified, remote filenames are mapped during 581.Ic mput 582commands and 583.Ic put 584commands issued without a specified remote target filename. 585If arguments are specified, local filenames are mapped during 586.Ic mget 587commands and 588.Ic get 589commands issued without a specified local target filename. 590This command is useful when connecting to a 591.No non\- Ns Ux 592remote computer 593with different file naming conventions or practices. 594The mapping follows the pattern set by 595.Ar inpattern 596and 597.Ar outpattern . 598.Ar inpattern 599is a template for incoming filenames (which may have already been 600processed according to the 601.Ic ntrans 602and 603.Ic case 604settings). 605Variable templating is accomplished by including the 606sequences 607.Ql $1 , 608.Ql $2 , 609..., 610.Ql $9 611in 612.Ar inpattern . 613Use 614.Ql \e 615to prevent this special treatment of the 616.Ql $ 617character. 618All other characters are treated literally, and are used to determine the 619.Ic nmap 620.Ar inpattern 621variable values. 622For example, given 623.Ar inpattern 624$1.$2 and the remote file name "mydata.data", $1 would have the value 625"mydata", and $2 would have the value "data". 626The 627.Ar outpattern 628determines the resulting mapped filename. 629The sequences 630.Ql $1 , 631.Ql $2 , 632..., 633.Ql $9 634are replaced by any value resulting from the 635.Ar inpattern 636template. 637The sequence 638.Ql $0 639is replaced by the original filename. 640Additionally, the sequence 641.Ql Op Ar seq1 , Ar seq2 642is replaced by 643.Op Ar seq1 644if 645.Ar seq1 646is not a null string; otherwise it is replaced by 647.Ar seq2 . 648For example, the command 649.Pp 650.Bd -literal -offset indent -compact 651nmap $1.$2.$3 [$1,$2].[$2,file] 652.Ed 653.Pp 654would yield 655the output filename 656.Pa myfile.data , 657for input filenames 658.Pa myfile.data 659and 660.Pa myfile.data.old , 661.Pa myfile.file 662for the input filename 663.Pa myfile , 664and 665.Pa myfile.myfile 666for the input filename 667.Pa \&.myfile . 668Spaces may be included in 669.Ar outpattern , 670as in the example 671.Pp 672.Bd -literal -offset indent -compact 673nmap $1 sed "s/ *$//" > $1 . 674.Ed 675.Pp 676Use the 677.Ql \e 678character to prevent special treatment 679of the 680.Ql $ , 681.Ql [ , 682.Ql \&] , 683and 684.Ql \&, 685characters. 686.It Ic ntrans Op Ar inchars Op Ar outchars 687Set or unset the filename character translation mechanism. 688If no arguments are specified, the filename character 689translation mechanism is unset. 690If arguments are specified, characters in 691remote filenames are translated during 692.Ic mput 693commands and 694.Ic put 695commands issued without a specified remote target filename. 696If arguments are specified, characters in 697local filenames are translated during 698.Ic mget 699commands and 700.Ic get 701commands issued without a specified local target filename. 702This command is useful when connecting to a 703.No non\- Ns Ux 704remote computer 705with different file naming conventions or practices. 706Characters in a filename matching a character in 707.Ar inchars 708are replaced with the corresponding character in 709.Ar outchars . 710If the character's position in 711.Ar inchars 712is longer than the length of 713.Ar outchars , 714the character is deleted from the file name. 715.It Ic open Ar host Op Ar port 716Establish a connection to the specified 717.Ar host 718.Tn FTP 719server. 720An optional port number may be supplied 721in which case 722.Nm 723will attempt to contact an 724.Tn FTP 725server at that port. 726If the 727.Ic auto-login 728option is on (default), 729.Nm 730will also attempt to automatically log the user in to 731the 732.Tn FTP 733server (see below). 734.It Ic page Ar file 735Retrieve 736.Ic file 737and display with the program defined in 738.Ev PAGER 739(defaulting to 740.Xr more 1 741if 742.Ev PAGER 743is null or not defined). 744.It Ic passive 745Toggle passive mode. 746If passive mode is turned on (default is on), the ftp client will 747send a 748.Dv PASV 749command for all data connections instead of the usual 750.Dv PORT 751command. 752The 753.Dv PASV 754command requests that the remote server open a port for the data connection 755and return the address of that port. 756The remote server listens on that port and the client connects to it. 757When using the more traditional 758.Dv PORT 759command, the client listens on a port and sends that address to the remote 760server, who connects back to it. 761Passive mode is useful when using 762.Nm 763through a gateway router or host that controls the directionality of 764traffic. 765(Note that though ftp servers are required to support the 766.Dv PASV 767command by RFC 1123, some do not.) 768.It Ic preserve 769Toggle preservation of modification times on retrieved files. 770.It Ic progress 771Toggle display of transfer progress bar. 772The progress bar will be disabled for a transfer that has 773.Ar local-file 774as 775.Dq - 776or a command that starts with 777.Sq \&| . 778Refer to 779.Sx FILE NAMING CONVENTIONS 780for more information. 781.It Ic prompt 782Toggle interactive prompting. 783Interactive prompting 784occurs during multiple file transfers to allow the 785user to selectively retrieve or store files. 786If prompting is turned off (default is on), any 787.Ic mget 788or 789.Ic mput 790will transfer all files, and any 791.Ic mdelete 792will delete all files. 793.Pp 794When prompting is on, the following commands are available at a prompt: 795.Bl -tag -width 2n -offset indent 796.It Ic n 797Do not transfer the file. 798.It Ic a 799Answer 800.Dq yes 801to the current file and automatically answer 802.Dq yes 803to any remaining files for the current command. 804.It Ic p 805Answer 806.Dq yes 807to the current file and turn off prompt mode 808(as if 809.Dq prompt off 810had been given). 811.El 812.Pp 813Any other reponse will answer 814.Dq yes 815to the current file. 816.It Ic proxy Ar ftp-command 817Execute an ftp command on a secondary control connection. 818This command allows simultaneous connection to two remote ftp 819servers for transferring files between the two servers. 820The first 821.Ic proxy 822command should be an 823.Ic open , 824to establish the secondary control connection. 825Enter the command 826.Ic proxy ? 827to see other ftp commands executable on the 828secondary connection. 829The following commands behave differently when prefaced by 830.Ic proxy : 831.Ic open 832will not define new macros during the auto-login process, 833.Ic close 834will not erase existing macro definitions, 835.Ic get 836and 837.Ic mget 838transfer files from the host on the primary control connection 839to the host on the secondary control connection, and 840.Ic put , 841.Ic mput , 842and 843.Ic append 844transfer files from the host on the secondary control connection 845to the host on the primary control connection. 846Third party file transfers depend upon support of the ftp protocol 847.Dv PASV 848command by the server on the secondary control connection. 849.It Ic put Ar local-file Op Ar remote-file 850Store a local file on the remote machine. 851If 852.Ar remote-file 853is left unspecified, the local file name is used 854after processing according to any 855.Ic ntrans 856or 857.Ic nmap 858settings 859in naming the remote file. 860File transfer uses the 861current settings for 862.Ic type , 863.Ic format , 864.Ic mode , 865and 866.Ic structure . 867.It Ic pwd 868Print the name of the current working directory on the remote 869machine. 870.It Ic quit 871A synonym for 872.Ic bye . 873.It Ic quote Ar arg1 arg2 ... 874The arguments specified are sent, verbatim, to the remote 875.Tn FTP 876server. 877.It Ic recv Ar remote-file Op Ar local-file 878A synonym for 879.Ic get . 880.It Ic reget Ar remote-file Op Ar local-file 881Reget acts like get, except that if 882.Ar local-file 883exists and is 884smaller than 885.Ar remote-file , 886.Ar local-file 887is presumed to be 888a partially transferred copy of 889.Ar remote-file 890and the transfer 891is continued from the apparent point of failure. 892This command 893is useful when transferring very large files over networks that 894are prone to dropping connections. 895.It Ic remotehelp Op Ar command-name 896Request help from the remote 897.Tn FTP 898server. 899If a 900.Ar command-name 901is specified it is supplied to the server as well. 902.It Ic rstatus Op Ar file-name 903With no arguments, show status of remote machine. 904If 905.Ar file-name 906is specified, show status of 907.Ar file-name 908on remote machine. 909.It Ic rename Op Ar from Op Ar to 910Rename the file 911.Ar from 912on the remote machine to the file 913.Ar to . 914.It Ic reset 915Clear reply queue. 916This command re-synchronizes command/reply sequencing with the remote 917ftp server. 918Resynchronization may be necessary following a violation of the ftp protocol 919by the remote server. 920.It Ic restart Ar marker 921Restart the immediately following 922.Ic get 923or 924.Ic put 925at the 926indicated 927.Ar marker . 928On 929.Ux 930systems, 931.Ar marker 932is usually a byte 933offset into the file. 934.It Ic rmdir Ar directory-name 935Delete a directory on the remote machine. 936.It Ic runique 937Toggle storing of files on the local system with unique filenames. 938If a file already exists with a name equal to the target 939local filename for a 940.Ic get 941or 942.Ic mget 943command, a 944.Dq \&.1 945is appended to the name. 946If the resulting name matches another existing file, 947a 948.Dq \&.2 949is appended to the original name. 950If this process continues up to 951.Dq \&.99 , 952an error 953message is printed, and the transfer does not take place. 954The generated unique filename will be reported. 955Note that 956.Ic runique 957will not affect local files generated from a shell command 958(see below). 959The default value is off. 960.It Ic send Ar local-file Op Ar remote-file 961A synonym for 962.Ic put . 963.It Ic sendport 964Toggle the use of 965.Dv PORT 966commands. 967By default, 968.Nm 969will attempt to use a 970.Dv PORT 971command when establishing 972a connection for each data transfer. 973The use of 974.Dv PORT 975commands can prevent delays 976when performing multiple file transfers. 977If the 978.Dv PORT 979command fails, 980.Nm 981will use the default data port. 982When the use of 983.Dv PORT 984commands is disabled, no attempt will be made to use 985.Dv PORT 986commands for each data transfer. 987This is useful 988for certain 989.Tn FTP 990implementations which do ignore 991.Dv PORT 992commands but, incorrectly, indicate they've been accepted. 993.It Ic site Ar arg1 arg2 ... 994The arguments specified are sent, verbatim, to the remote 995.Tn FTP 996server as a 997.Dv SITE 998command. 999.It Ic size Ar file-name 1000Return size of 1001.Ar file-name 1002on remote machine. 1003.It Ic status 1004Show the current status of 1005.Nm ftp . 1006.It Ic struct Op Ar struct-name 1007Set the file transfer 1008.Ar structure 1009to 1010.Ar struct-name . 1011By default \*(Lqstream\*(Rq structure is used. 1012.It Ic sunique 1013Toggle storing of files on remote machine under unique file names. 1014Remote ftp server must support ftp protocol 1015.Dv STOU 1016command for 1017successful completion. 1018The remote server will report unique name. 1019Default value is off. 1020.It Ic system 1021Show the type of operating system running on the remote machine. 1022.It Ic tenex 1023Set the file transfer type to that needed to 1024talk to 1025.Tn TENEX 1026machines. 1027.It Ic trace 1028Toggle packet tracing. 1029.It Ic type Op Ar type-name 1030Set the file transfer 1031.Ic type 1032to 1033.Ar type-name . 1034If no type is specified, the current type 1035is printed. 1036The default type is network 1037.Tn ASCII . 1038.It Ic umask Op Ar newmask 1039Set the default umask on the remote server to 1040.Ar newmask . 1041If 1042.Ar newmask 1043is omitted, the current umask is printed. 1044.It Xo 1045.Ic user Ar user-name 1046.Op Ar password Op Ar account 1047.Xc 1048Identify yourself to the remote 1049.Tn FTP 1050server. 1051If the 1052.Ar password 1053is not specified and the server requires it, 1054.Nm 1055will prompt the user for it (after disabling local echo). 1056If an 1057.Ar account 1058field is not specified, and the 1059.Tn FTP 1060server 1061requires it, the user will be prompted for it. 1062If an 1063.Ar account 1064field is specified, an account command will 1065be relayed to the remote server after the login sequence 1066is completed if the remote server did not require it 1067for logging in. 1068Unless 1069.Nm 1070is invoked with \*(Lqauto-login\*(Rq disabled, this 1071process is done automatically on initial connection to 1072the 1073.Tn FTP 1074server. 1075.It Ic verbose 1076Toggle verbose mode. 1077In verbose mode, all responses from 1078the 1079.Tn FTP 1080server are displayed to the user. 1081In addition, 1082if verbose is on, when a file transfer completes, statistics 1083regarding the efficiency of the transfer are reported. 1084By default, 1085verbose is on. 1086.It Ic ? Op Ar command 1087A synonym for 1088.Ic help . 1089.El 1090.Pp 1091Command arguments which have embedded spaces may be quoted with 1092quote 1093.Pq Ql " 1094marks. 1095.Pp 1096Commands which toggle settings can take an explicit 1097.Ic on 1098or 1099.Ic off 1100argument to force the setting appropriately. 1101.Pp 1102If 1103.Nm 1104receives a 1105.Dv SIGINFO 1106(see the 1107.Dq status 1108argument of 1109.Xr stty 1 ) 1110signal whilst a transfer is in progress, the current transfer rate 1111statistics will be written to the standard error output, in the 1112same format as the standard completion message. 1113.Sh AUTO-FETCHING FILES 1114In addition to standard commands, this version of 1115.Nm 1116supports an auto-fetch feature. 1117To enable auto-fetch, simply pass the list of hostnames/files 1118on the command line. 1119.Pp 1120The following formats are valid syntax for an auto-fetch element: 1121.Bl -tag -width "ftp://[user:password@]host[:port]/file" 1122.It host:/file 1123.Dq Classic 1124ftp format 1125.It ftp://[user:password@]host[:port]/file 1126An ftp URL, retrieved using the ftp protocol if 1127.Ev ftp_proxy 1128isn't defined. 1129Otherwise, transfer using http via the proxy defined in 1130.Ev ftp_proxy . 1131If 1132.Ar user:password@ 1133is given and 1134.Ev ftp_proxy 1135isn't defined, login as 1136.Ar user 1137with a password of 1138.Ar password . 1139.It http://host[:port]/file 1140An http URL, retrieved using the http protocol. 1141If 1142.Ev http_proxy 1143is defined, it is used as a URL to an HTTP proxy server. 1144.El 1145.Pp 1146If a classic format or a ftp URL format has a trailing 1147.Sq / , 1148then 1149.Nm 1150will connect to the site and 1151.Ic cd 1152to the directory given as the path, and leave the user in interactive 1153mode ready for further input. 1154.Pp 1155If successive auto-fetch ftp elements refer to the same host, then 1156the connection is maintained between transfers, reducing overhead on 1157connection creation and deletion. 1158.Pp 1159If 1160.Ic file 1161contains a glob character and globbing is enabled, 1162(see 1163.Ic glob ) , 1164then the equivalent of 1165.Ic "mget file" 1166is performed. 1167.Pp 1168If no 1169.Fl o 1170option is specified, and 1171the directory component of 1172.Ic file 1173contains no globbing characters, 1174then 1175it is stored in the current directory as the 1176.Xr basename 1 1177of 1178.Ic file . 1179Otherwise, the remote name is used as the local name. 1180.Sh ABORTING A FILE TRANSFER 1181To abort a file transfer, use the terminal interrupt key 1182(usually Ctrl-C). 1183Sending transfers will be immediately halted. 1184Receiving transfers will be halted by sending an ftp protocol 1185.Dv ABOR 1186command to the remote server, and discarding any further data received. 1187The speed at which this is accomplished depends upon the remote 1188server's support for 1189.Dv ABOR 1190processing. 1191If the remote server does not support the 1192.Dv ABOR 1193command, an 1194.Ql ftp> 1195prompt will not appear until the remote server has completed 1196sending the requested file. 1197.Pp 1198The terminal interrupt key sequence will be ignored when 1199.Nm 1200has completed any local processing and is awaiting a reply 1201from the remote server. 1202A long delay in this mode may result from the ABOR processing described 1203above, or from unexpected behavior by the remote server, including 1204violations of the ftp protocol. 1205If the delay results from unexpected remote server behavior, the local 1206.Nm 1207program must be killed by hand. 1208.Sh FILE NAMING CONVENTIONS 1209Files specified as arguments to 1210.Nm 1211commands are processed according to the following rules. 1212.Bl -enum 1213.It 1214If the file name 1215.Dq - 1216is specified, the standard input (for reading) 1217or standard output (for writing) 1218is used. 1219.It 1220If the first character of the file name is 1221.Sq \&| , 1222the 1223remainder of the argument is interpreted as a shell command. 1224.Nm 1225then forks a shell, using 1226.Xr popen 3 1227with the argument supplied, and reads (writes) from the standard output 1228(standard input). 1229If the shell command includes spaces, the argument 1230must be quoted; e.g., 1231\*(Lq" ls -lt"\*(Rq. 1232A particularly 1233useful example of this mechanism is: \*(Lqdir \&|more\*(Rq. 1234.It 1235Failing the above checks, if 1236.Dq globbing 1237is enabled, 1238local file names are expanded 1239according to the rules used in the 1240.Xr csh 1 ; 1241c.f. the 1242.Ic glob 1243command. 1244If the 1245.Nm 1246command expects a single local file (e.g., 1247.Ic put ) , 1248only the first filename generated by the 1249.Dq globbing 1250operation is used. 1251.It 1252For 1253.Ic mget 1254commands and 1255.Ic get 1256commands with unspecified local file names, the local filename is 1257the remote filename, which may be altered by a 1258.Ic case , 1259.Ic ntrans , 1260or 1261.Ic nmap 1262setting. 1263The resulting filename may then be altered if 1264.Ic runique 1265is on. 1266.It 1267For 1268.Ic mput 1269commands and 1270.Ic put 1271commands with unspecified remote file names, the remote filename is 1272the local filename, which may be altered by a 1273.Ic ntrans 1274or 1275.Ic nmap 1276setting. 1277The resulting filename may then be altered by the remote server if 1278.Ic sunique 1279is on. 1280.El 1281.Sh FILE TRANSFER PARAMETERS 1282The FTP specification specifies many parameters which may 1283affect a file transfer. 1284The 1285.Ic type 1286may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary), 1287\*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for 1288.Tn PDP Ns -10's 1289and 1290.Tn PDP Ns -20's 1291mostly). 1292.Nm 1293supports the ascii and image types of file transfer, 1294plus local byte size 8 for 1295.Ic tenex 1296mode transfers. 1297.Pp 1298.Nm 1299supports only the default values for the remaining 1300file transfer parameters: 1301.Ic mode , 1302.Ic form , 1303and 1304.Ic struct . 1305.Sh THE .netrc FILE 1306The 1307.Pa .netrc 1308file contains login and initialization information 1309used by the auto-login process. 1310It resides in the user's home directory. 1311The following tokens are recognized; they may be separated by spaces, 1312tabs, or new-lines: 1313.Bl -tag -width password 1314.It Ic machine Ar name 1315Identify a remote machine 1316.Ar name . 1317The auto-login process searches the 1318.Pa .netrc 1319file for a 1320.Ic machine 1321token that matches the remote machine specified on the 1322.Nm 1323command line or as an 1324.Ic open 1325command argument. 1326Once a match is made, the subsequent 1327.Pa .netrc 1328tokens are processed, 1329stopping when the end of file is reached or another 1330.Ic machine 1331or a 1332.Ic default 1333token is encountered. 1334.It Ic default 1335This is the same as 1336.Ic machine 1337.Ar name 1338except that 1339.Ic default 1340matches any name. 1341There can be only one 1342.Ic default 1343token, and it must be after all 1344.Ic machine 1345tokens. 1346This is normally used as: 1347.Pp 1348.Dl default login anonymous password user@site 1349.Pp 1350thereby giving the user 1351.Ar automatic 1352anonymous ftp login to 1353machines not specified in 1354.Pa .netrc . 1355This can be overridden 1356by using the 1357.Fl n 1358flag to disable auto-login. 1359.It Ic login Ar name 1360Identify a user on the remote machine. 1361If this token is present, the auto-login process will initiate 1362a login using the specified 1363.Ar name . 1364.It Ic password Ar string 1365Supply a password. 1366If this token is present, the auto-login process will supply the 1367specified string if the remote server requires a password as part 1368of the login process. 1369Note that if this token is present in the 1370.Pa .netrc 1371file for any user other 1372than 1373.Ar anonymous , 1374.Nm 1375will abort the auto-login process if the 1376.Pa .netrc 1377is readable by 1378anyone besides the user. 1379.It Ic account Ar string 1380Supply an additional account password. 1381If this token is present, the auto-login process will supply the 1382specified string if the remote server requires an additional 1383account password, or the auto-login process will initiate an 1384.Dv ACCT 1385command if it does not. 1386.It Ic macdef Ar name 1387Define a macro. 1388This token functions like the 1389.Nm 1390.Ic macdef 1391command functions. 1392A macro is defined with the specified name; its contents begin with the 1393next 1394.Pa .netrc 1395line and continue until a null line (consecutive new-line 1396characters) is encountered. 1397If a macro named 1398.Ic init 1399is defined, it is automatically executed as the last step in the 1400auto-login process. 1401.El 1402.Sh COMMAND LINE EDITING 1403.Nm 1404supports interactive command line editing, via the 1405.Xr editline 3 1406library. 1407It is enabled with the 1408.Ic edit 1409command, and is enabled by default if input is from a tty. 1410Previous lines can be recalled and edited with the arrow keys, 1411and other GNU Emacs-style editing keys may be used as well. 1412.Pp 1413The 1414.Xr editline 3 1415library is configured with a 1416.Pa .editrc 1417file - refer to 1418.Xr editrc 5 1419for more information. 1420.Pp 1421An extra key binding is available to 1422.Nm 1423to provide context sensitive command and filename completion 1424(including remote file completion). 1425To use this, bind a key to the 1426.Xr editline 3 1427command 1428.Ic ftp-complete . 1429By default, this is bound to the TAB key. 1430.Sh ENVIRONMENT 1431.Nm 1432utilizes the following environment variables: 1433.Bl -tag -width "FTPSERVERPORT" 1434.It Ev FTPMODE 1435Overrides the default operation mode. 1436Recognized values are: 1437.Bl -tag -width "passive " 1438.It passive 1439passive mode ftp only 1440.It active 1441active mode ftp only 1442.It auto 1443automatic determination of passive or active (this is the default) 1444.It gate 1445gate-ftp mode 1446.El 1447.It Ev FTPSERVER 1448Host to use as gate-ftp server when 1449.Ic gate 1450is enabled. 1451.It Ev FTPSERVERPORT 1452Port to use when connecting to gate-ftp server when 1453.Ic gate 1454is enabled. 1455Default is port returned by a 1456.Fn getservbyname 1457lookup of 1458.Dq ftpgate/tcp . 1459.It Ev HOME 1460For default location of a 1461.Pa .netrc 1462file, if one exists. 1463.It Ev PAGER 1464Used by 1465.Ic page 1466to display files. 1467.It Ev SHELL 1468For default shell. 1469.It Ev TMPDIR 1470Directory to put temporary files. 1471.It Ev ftp_proxy 1472URL of FTP proxy to use when making FTP URL requests 1473(if not defined, use the standard ftp protocol). 1474.It Ev http_proxy 1475URL of HTTP proxy to use when making HTTP URL requests. 1476.El 1477.Sh SEE ALSO 1478.Xr tftp 1 , 1479.Xr getservbyname 3 , 1480.Xr editrc 5 , 1481.Xr services 5 , 1482.Xr ftpd 8 1483.Sh HISTORY 1484The 1485.Nm 1486command appeared in 1487.Bx 4.2 . 1488.Sh BUGS 1489Correct execution of many commands depends upon proper behavior 1490by the remote server. 1491.Pp 1492An error in the treatment of carriage returns 1493in the 1494.Bx 4.2 1495ASCII-mode transfer code 1496has been corrected. 1497This correction may result in incorrect transfers of binary files 1498to and from 1499.Bx 4.2 1500servers using the ASCII type. 1501Avoid this problem by using the binary image type. 1502