[BACK]Return to ftp.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / ftp

Annotation of src/usr.bin/ftp/ftp.1, Revision 1.35

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