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

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