[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.29

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