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

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