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

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