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

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