home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / ftp.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  25.2 KB  |  563 lines

  1.  
  2. FTP(1C)
  3.  
  4. NAME ftp - file transfer program
  5.  
  6. SyNOPSIS fftp [ -v ] [ -d ] [ -i ] [ -n ] [ -g ] [
  7.    host ]
  8.  
  9. DESCRIPTION fftp is the user interface to the DARPA File Transfer
  10.    Protocol. The pro- gram transfers files to and from a remote network
  11.    site. For file transfers between 4.2 and 4.3 UNIX-based hosts on a
  12.    local network, rcp is preferable.
  13.  
  14.    The client host with which fftp is to communicate can be specified on
  15.    the command line. In this case, fftp immediately attempts to
  16.    establish a con- nection to an FTP server on that host; otherwise,
  17.    fftp enters its command interpreter and waits for instruction,
  18.    displaying the prompt ``ftp>''.
  19.  
  20.    ftp recognizes the following commands:
  21.  
  22.    !         Invoke a shell on the local machine.
  23.  
  24.    $ macroname [ args ] Execute the macro macroname that was defined
  25.              with the macdef command.  Arguments are passed
  26.              to the macro unglobbed.
  27.  
  28.    account [ passwd ] Supply a supplemental password required
  29.              by a remote system for access to resources once a login has
  30.              been successfully com- pleted.  If no argument is included,
  31.              the user will be prompted for an account password in a
  32.              non-echoing input mode.
  33.  
  34.    append localfile [ remotefile ] Append a local file to a
  35.              file on the remote machine. If remotefile is left
  36.              unspecified, the local file name is used to name the remote
  37.              file. File transfer uses the current set- tings for
  38.              type, format, mode, and
  39.              structure.
  40.  
  41.    ascii     Set the file transfer type to network ASCII.
  42.              This is the default.
  43.  
  44.    bell      Sound a bell after each file transfer command is
  45.    completed.
  46.  
  47.    binary    Set the file transfer type to support
  48.    binary image transfer.
  49.  
  50.    bye       Terminate the FTP session with the remote server and
  51.    exit fftp.
  52.  
  53.    case      Toggle remote computer file name case-mapping during
  54.              mget com- mands.  When case is on (default is
  55.              off), remote computer file names with all letters in
  56.              upper-case are written in the local directory with the
  57.              letters mapped to lower-case.
  58.  
  59.    cd remotedir Change the working directory on the remote machine
  60.              to remotedir.
  61.  
  62.    cdup      Change the remote machine working directory to its
  63.    parent.
  64.  
  65. FTP(1C)
  66.  
  67.    close     Terminate the FTP session with the remote server, and
  68.              return to the command interpreter.
  69.  
  70.    cr        Toggle carriage return stripping during ASCII-type file
  71.              retrieval.  Records are denoted by a carriage
  72.              return/linefeed sequence during ASCII-type file transfer.
  73.              When cr is on (the default), carriage returns are
  74.              stripped from this sequence to conform with the UNIX single
  75.              linefeed record delimiter. Records on non-UNIX remote
  76.              systems can contain single linefeeds; when an ASCII type
  77.              transfer is made, these linefeeds can be distinguished from
  78.              a record delimiter only when cr is off.
  79.  
  80.    debug [ debugvalue ] Toggle debugging mode. If an optional
  81.              debugvalue is speci- fied, it is used to set the debugging
  82.              level. When debugging is on, fftp prints each command sent
  83.              to the remote machine, pre- ceded by the string --> .
  84.  
  85.    delete remotefile Delete the file remotefile on the remote
  86.              machine.
  87.  
  88.    dir [ remotedir ] [ localfile ] Print the contents of
  89.              directory, remotedir, and, optionally, place the output in
  90.              localfile.  If no directory is specified, the current
  91.              working directory on the remote machine is used. If no
  92.              local file is specified, output comes to the terminal.
  93.  
  94.    disconnect A synonym for close.
  95.  
  96.    form format Set the file transfer form to format.  The
  97.              default format is ``file''.
  98.  
  99.    get remotefile [ localfile ] Retrieve the remotefile and store it
  100.              on the local machine. If the local file name is not
  101.              specified, it is given the same name it has on the remote
  102.              machine. The current settings for type, form,
  103.              mode, and structure are used while
  104.              transferring the file.
  105.  
  106.    glob      Toggle file name globbing. With file name globbing enabled,
  107.              each local file or pathname is processed for csh
  108.              metacharac- ters. These characters are * ? [] ~ {}.  Remote
  109.              files speci- fied in multiple item commands, such as
  110.              mput, are globbed by the remote server. With globbing
  111.              disabled, all files and path- names are treated literally.
  112.  
  113.    glob      Toggle filename expansion for mdelete, mget
  114.              and mput.  If globbing is turned off with glob, the
  115.              file name arguments are taken literally and not expanded.
  116.              Globbing for mput is done as in csh.  For
  117.              mdelete and mget, each remote file name is
  118.              expanded separately on the remote machine and the lists are
  119.              not merged.  Expansion of a directory name is likely to be
  120.              different from expansion of the name of an ordinary file;
  121.              the
  122.  
  123. 2  UMAX 4.3 User's Reference Manual
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. FTP(1C)
  131.  
  132.              exact result depends on the foreign operating system and
  133.              FTP server, and can be previewed by doing ``mls
  134.              remotefiles''. Note: mget and mput are not meant
  135.              to transfer entire directory subtrees of files.  That can
  136.              be done by transferring a tar archive of the subtree
  137.              (in binary mode).
  138.  
  139.    hash      Toggle number-sign (#) printing for each data block
  140.              transferred. The size of a data block is 1024 bytes.
  141.  
  142.    help command Print a description of command.  With no argument,
  143.              fftp prints a list of the known commands.
  144.  
  145.    lcd [ dir ] Change the working directory dir on the local
  146.              machine. If dir is not specified, change to the user's home
  147.              directory.
  148.  
  149.    ls [ remotedir ] [ localfile ] Print an abbreviated listing of the
  150.              contents of a directory on the remote machine. If remotedir
  151.              is left unspecified, the current working directory is used.
  152.              If no local-file is speci- fied, the output is sent to the
  153.              terminal.
  154.  
  155.    macdef macroname Define a macro.  Subsequent lines are
  156.              stored as the macro macroname; a null line (consecutive
  157.              newline characters in a file or carriage returns from the
  158.              terminal) terminates macro input mode.  There is a limit of
  159.              16 macros and 4096 total characters in all defined macros.
  160.              Macros remain defined until a close command is
  161.              executed.  The macro processor interprets $ and \\\ as
  162.              special characters.  A $ followed by a number (or
  163.              numbers) is replaced by the corresponding argument on the
  164.              macro invocation command line.  A $ followed by an i
  165.              signals that macro processor that the executing macro is to
  166.              be looped. On the first pass $i is replaced by the
  167.              first argument on the macro invocation command line, on the
  168.              second pass it is replaced by the second argument, and so
  169.              on.  A \\\ followed by any character is replaced by that
  170.              character.  Use the \\\ to prevent special treatment of the
  171.              $.
  172.  
  173.    mdelete remotefiles Delete the specified files on the
  174.              remote machine. If globbing is enabled, the remote file
  175.              specification is first expanded using ls.
  176.  
  177.    mdir remotefiles localfile Obtain a directory listing of
  178.              multiple files on the remote machine and place the result
  179.              in localfile.
  180.  
  181.    mget remotefiles Retrieve the specified files from the remote
  182.              machine and place them in the current local directory. If
  183.              globbing is enabled, the specification of remote files will
  184.              first be expanded using ls.
  185.  
  186.    mkdir dirname
  187.  
  188.                                         UMAX 4.3 User's Reference Manual
  189.                                         3
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. FTP(1C)
  197.  
  198.              Make a directory named dirname on the remote machine.
  199.  
  200.    mls remotefiles localfile Obtain an abbreviated listing of multiple
  201.              files on the remote machine and place the result in
  202.              localfile.
  203.  
  204.    mode [ modename ] Set the file transfer mode to modename.
  205.              The default mode is stream.
  206.  
  207.    mput localfiles Expand wildcards in the list of local files
  208.              given as arguments and do a put for each file in the
  209.              resulting list. This transfers multiple local files from
  210.              the current local direc- tory to the current working
  211.              directory on the remote machine. See csh for details of
  212.              filename expansion.  Resulting file names will then be
  213.              processed according to ntrans and nmap set-
  214.              tings.
  215.  
  216.    nmap [ inpattern outpattern ] Set or unset the filename
  217.              mapping mechanism.  If no arguments are specified, the
  218.              filename mapping mechanism is unset.  If arguments are
  219.              specified, remote filenames are mapped during mput
  220.              commands and put commands issued without a specified
  221.              remote target filename.  If arguments are specified, local
  222.              filenames are mapped during mget commands and get
  223.              commands issued without a specified local target filename.
  224.              This com- mand is useful when connecting to a non-UNIX
  225.              remote computer with different file naming conventions or
  226.              practices.  The map- ping follows the pattern set by
  227.              inpattern and outpattern.
  228.  
  229.              inpattern is a template for incoming filenames (which may
  230.              have already been processed according to the ntrans
  231.              and case set- tings).  Variable templating is
  232.              accomplished by including the sequences ``$1'', ``$2'',
  233.              ..., ``$9'' in inpattern.  Use \\\ to prevent this special
  234.              treatment of the $ character.  All other characters are
  235.              treated literally, and are used to determine the
  236.              nmap inpattern variable values.  For example, given
  237.              inpat- tern $1.$2 and the remote file name
  238.              mydata...data, $1 would have the value
  239.              ``mydata'', and $2 would have the value ``data''.
  240.  
  241.              The outpattern determines the resulting mapped filename.
  242.              The sequences ``$1'', ``$2'', ...., ``$9'' are replaced by
  243.              any value resulting from the inpattern template.  The
  244.              sequence ``$0'' is replace by the original filename.
  245.              Additionally, the sequence [seq1,seq2] is replaced by seq1
  246.              if seq1 is not a null string; otherwise it is replaced by
  247.              seq2.  For example, the command ``nmap $1.$2.$3
  248.              [$1,$2].[$2,file]'' would yield the output filename
  249.              myfile...data for input filenames
  250.              myfile...data and
  251.              myfile...data...old,
  252.              myfile...file for the input filename
  253.              myfile, and myfile...myfile
  254.              for the input filename ...myfile. Spaces can be
  255.              included in outpattern, as in the example: nmap $1 |sed "s/
  256.              *$//" > $1 .  Use the \\\ character to prevent spe- cial
  257.              treatment of ``$'', ``['', ``]'', and ``,''.
  258.  
  259.    ntrans [ inchars [ outchars ] ]
  260.  
  261. FTP(1C)
  262.  
  263.              Set or unset the filename character translation mechanism.
  264.              If no arguments are specified, the filename character
  265.              translation mechanism is unset.  If arguments are
  266.              specified, characters in remote filenames are translated
  267.              during mput commands and put commands issued
  268.              without a specified remote target filename. If arguments
  269.              are specified, characters in local filenames are translated
  270.              during mget commands and get commands issued without
  271.              a specified local target filename.  This command is useful
  272.              when connecting to a non-UNIX remote computer with dif-
  273.              ferent file naming conventions or practices.  Characters in
  274.              a filename matching a character in inchars are replaced
  275.              with the corresponding character in outchars.  If the
  276.              character's posi- tion in inchars is longer than the length
  277.              of outchars, the character is deleted from the file name.
  278.  
  279.    open host [ port ] Establish a connection to the specified
  280.              host's FTP server. An optional port number can be
  281.              supplied, in which case, fftp attempts to contact an FTP
  282.              server at that port. If the auto- login option is
  283.              on (default), fftp also attempts to automati- cally log the
  284.              user in to the FTP server (see below).
  285.  
  286.    prompt    Toggle interactive prompting. Interactive prompting
  287.              occurs during multiple file transfers to allow the user to
  288.              selec- tively retrieve or store files. If prompting is
  289.              turned off (default), any mget or mput transfers
  290.              all files.
  291.  
  292.    proxy ftpcommand Execute an FTP command on a secondary
  293.              control connection. This command allows simultaneous
  294.              connection to two remote FTP servers for transferring files
  295.              between the two servers.  The first proxy command
  296.              should be an open, to establish the secon- dary
  297.              control connection.  Enter the command ``proxy ?'' to see
  298.              other FTP commands executable on the secondary connection.
  299.              The following commands behave differently when prefaced by
  300.              proxy: open will not define new macros during
  301.              the auto-login process, close will not erase existing
  302.              macro definitions, get and mget transfer files from
  303.              the host on the primary control connection to the host on
  304.              the secondary control connection, and put, mput,
  305.              and append transfer files from the host on the
  306.              secondary control connection to the host on the primary
  307.              con- trol connection.  Third-party file transfers depend
  308.              upon sup- port of the FTP protocol PASV command by the
  309.              server on the secondary control connection.
  310.  
  311.    put localfile [ remotefile ] Store a local file on the remote
  312.              machine. If remotefile is left unspecified, the local file
  313.              name is used in naming the remote file. File transfer uses
  314.              the current settings for type, format,
  315.              mode, and structure.
  316.  
  317.    pwd       Print the name of the current working directory on
  318.              the remote machine.
  319.  
  320.    quit      A synonym for bye...
  321.  
  322.  
  323.                                         UMAX 4.3 User's Reference Manual
  324.                                         5
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. FTP(1C)
  332.  
  333.    quote arg1 arg2 ... The arguments specified are sent, verbatim,
  334.              to the remote FTP server. A single FTP reply code is
  335.              expected in return.
  336.  
  337.    recv remotefile [ localfile ] A synonym for get.
  338.  
  339.    remotehelp [ commandname ] Request help from the remote
  340.              FTP server. If a commandname is specified, it is supplied
  341.              to the server as well.
  342.  
  343.    rename [ from ] [ to ] Rename, on the remote machine, the
  344.              file from to the file to.
  345.  
  346.    reset     Clear reply queue.  This command resynchronizes
  347.              command/reply sequencing with the remote FTP server.
  348.              Resynchronization may be neccesary following a violation of
  349.              the FTP protocol by the remote server.
  350.  
  351.    rmdir dirname Delete the directory dirname on the remote
  352.              machine.
  353.  
  354.    runique   Toggle storing of files on the local system
  355.              with unique filenames.  If a file already exists with a
  356.              name equal to the target local filename for a get or
  357.              mget command, a ``.1'' is appended to the name.  If the
  358.              resulting name matches another existing file, a ``.2'' is
  359.              appended to the original name.  If this process continues
  360.              up to ``.99'', an error message is printed, and the
  361.              transfer does not take place.  The generated unique
  362.              filename will be reported.  Note that runique
  363.              will not affect local files generated from a shell command
  364.              (see below). The default value is off.
  365.  
  366.    send localfile [ remotefile ] A synonym for put.
  367.  
  368.    sendport  Toggle the use of PORT commands. By default, fftp
  369.              attempts to use a PORT command when establishing a
  370.              connection for each data transfer. If the PORT command
  371.              fails, fftp uses the default data port. When the use of
  372.              PORT commands is disabled, no attempt is made to use them
  373.              for each data transfer. This is useful for certain FTP
  374.              implementations that do ignore PORT commands but wrongly
  375.              indicate they have been accepted.
  376.  
  377.    status    Show the current status of fftp.
  378.  
  379.    struct [ structname ] Set the file transfer
  380.              structure to structname.  The default structure
  381.              is stream.
  382.  
  383.    sunique   Toggle storing of files on remote machine under
  384.              unique file names.  Remote FTP server must support FTP
  385.              protocol STOU com- mand for successful completion.  The
  386.              remote server will report unique names.  Default value is
  387.              off.
  388.  
  389.    tenex     Set the file transfer type to that needed to talk
  390.    to TENEX
  391.  
  392. FTP(1C)
  393.  
  394.              machines.
  395.  
  396.    trace     Toggle packet-tracing.
  397.  
  398.    type [ typename ] Set the file transfer type to typename.  If
  399.              no type is speci- fied, the current type is printed. The
  400.              default type is network ASCII.
  401.  
  402.    user username [ password ] [ account ] Identify yourself to the
  403.              remote FTP server. If the password is not specified and the
  404.              server requires it, fftp prompts the user for it (after
  405.              disabling local echo).  If an account field is not
  406.              specified, and the FTP server requires it, the user is
  407.              prompted for it. Unless fftp is invoked with ``auto-login''
  408.              disabled, this process is done automatically on initial
  409.              con- nection to the FTP server.
  410.  
  411.    verbose   Toggle verbose mode. In verbose mode, all responses
  412.              from the FTP server are displayed to the user. In addition,
  413.              if verbose mode is on, when a file transfer completes,
  414.              statistics regard- ing the efficiency of the transfer are
  415.              reported. By default, verbose is on.
  416.  
  417.    ??? [ command ] A synonym for help.
  418.  
  419.    Command arguments that have embedded spaces can be quoted with double
  420.    quote (") marks.
  421.  
  422. ABORTING A FILE TRANSFER To abort a file transfer, use the terminal
  423.    interrupt key (usually CTRL- C).  Sending transfers are immediately
  424.    halted.  Receiving transfers are halted by sending an FTP protocol
  425.    ABOR command to the remote server, and discarding any further data
  426.    received.  The speed at which this is accom- plished depends upon the
  427.    remote server's support for ABOR processing. If the remote server
  428.    does not support the ABOR command, an ``ftp>'' prompt will not appear
  429.    until the remote server has completed sending the requested file.
  430.  
  431.    The terminal interrupt key sequence is ignored when fftp has
  432.    completed any local processing and is awaiting a reply from the
  433.    remote server.  A long delay in this mode can result from the ABOR
  434.    processing described above, or from unexpected behavior by the remote
  435.    server, including vio- lations of the FTP protocol.  If the delay
  436.    results from unexpected remote server behavior, the local FTP program
  437.    must be killed by hand.
  438.  
  439. FILE NAMING CONVENTIONS Files specified as arguments to FTP commands are
  440.    processed according to the following rules.
  441.  
  442.    1. If the file name is -, the standard input (for reading) or the
  443.       stan- dard output (for writing) is used.
  444.  
  445.    2. If the first character of the file name is a bar(|), the remainder
  446.       of the argument is interpreted as a shell command.  fftp then
  447.       forks a
  448.  
  449. FTP(1C)
  450.  
  451.       shell, using popen with the argument supplied, and reads
  452.       (writes) from the stdout (stdin).  If the shell command
  453.       includes spaces, the argument must be quoted; for example, """|||
  454.       ls -lt""". A particularly use- ful example of this mechanism is
  455.       """dir ||| more""".
  456.  
  457.    3. Failing the above checks, if globbing is enabled, local file names
  458.       are expanded according to the rules used in csh; see the glob
  459.       com- mand.
  460.  
  461.    4. For mget commands and get commands with unspecified local
  462.       file names, the local filename is the remote filename, which can
  463.       be altered by a case, ntrans, or nmap
  464.       setting.  The resulting filename can then be altered if
  465.       runique is on.
  466.  
  467.    5. For mput commands and put commands with unspecified
  468.       remote file names, the remote filename is the local filename,
  469.       which can be altered by a ntrans or nmap setting.
  470.       The resulting filename can then be altered by the remote server if
  471.       sunique is on.
  472.  
  473. FILE TRANSFER PARAMETERS The FTP specification identifies many
  474.    parameters that can affect a file transfer. The type can be one
  475.    of ASCII , image (binary), ebcdic, and local
  476.    byte size (for PDP-10's and PDP-20's mostly).  fftp
  477.    supports the ASCII and image types of file
  478.    transfer, plus local byte size 8 for tenex mode transfers.
  479.  
  480.    fftp supports only the default values for the remaining file transfer
  481.    parameters: mode, form, and struct.
  482.  
  483. OPTIONS Options can be specified at the command line, or to the command
  484.    inter- preter.
  485.  
  486.    -d   Enable debugging.
  487.  
  488.    -g   Disable file name globbing.
  489.  
  490.    -i   Turn off interactive prompting during mutiple file
  491.    transfers.
  492.  
  493.    -n   Restrain fftp from attempting auto-login upon initial
  494.         connection. If auto-login is enabled, fftp checks the
  495.         ...netrc file in the user's home directory for an entry
  496.         describing an account on the remote machine.  If no entry
  497.         exists, fftp prompts for the remote machine login name (default
  498.         is the user identity on the local machine), and, if necessary,
  499.         prompts for a password and an account with which to log-in.
  500.  
  501.    -v   Force fftp to show all responses from the remote server and
  502.         to report data transfer statistics.
  503.  
  504. THE .netrc FILE The ...netrc file contains login and
  505.    initialization information used by the auto-login process.  It
  506.    resides in the user's home directory.  The following identifiers are
  507.    recognized; they can be separated by spaces, tabs, or newlines.
  508.  
  509. FTP(1C)
  510.  
  511.    machine name Identify a remote machine name.  The
  512.       auto-login process searches the ...netrc file for a
  513.       machine identifier that matches the remote machine specified on
  514.       the FTP command line or as an open command argument. Once a
  515.       match is made, the subsequent ...netrc identifiers are
  516.       pro- cessed, stopping when the end-of-file is reached or another
  517.       machine identifier is encountered.
  518.  
  519.    login name Identify a user on the remote machine.  If this
  520.       identifier is present, the auto-login process initiates a login
  521.       using the specified name.
  522.  
  523.    password string Supply a password.  If this identifier is
  524.       present, the auto-login process supplies the specified string if
  525.       the remote server requires a password as part of the login
  526.       process.  Note that if this identifier is present in the
  527.       ...netrc file, fftp aborts the auto-login process if the
  528.       ...netrc is readable by anyone besides the user.
  529.  
  530. FTP(1C)
  531.  
  532.    account string Supply an additional account password.  If
  533.       this identifier is present, the auto-login process supplies the
  534.       specified string if the remote server requires an additional
  535.       account password, or the auto- login process initiates an ACCT
  536.       command if it does not.
  537.  
  538.    macdef name Define a macro.  This identifier functions
  539.       like the FTP macdef com- mand functions.  A macro is
  540.       defined with the specified name; its con- tents begin with the
  541.       next ...netrc line and continue until a null line
  542.       (consecutive newline characters) is encountered.  If a macro named
  543.       init is defined, it is automatically executed as the last
  544.       step in the auto-login process.
  545.  
  546. SEE ALSO csh(1), rcp(1) ftpd(8c) in the UMAX 4.3 System Administrator's
  547.    Reference Manual
  548.  
  549. RESTRICTIONS Many FTP server implementations do not support the
  550.    experimental opera- tions such as print working directory.
  551.  
  552.    Aborting a file transfer does not work right; if one attempts this,
  553.    the local FTP will probably have to be killed by hand.
  554.  
  555.    Correct execution of many commands depends upon proper behavior by
  556.    the remote server.
  557.  
  558.    An error in the treatment of carriage returns in the 4.2BSD UNIX
  559.    ASCII -mode transfer code has been corrected.  This correction can
  560.    result in incorrect transfers of binary files to and from 4.2BSD
  561.    servers using the ASCII type.  Avoid this problem by using the binary
  562.    image type.
  563.