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

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