Tuesday, May 30, 2006

FTP Commands

I. Opening and closing connection

  • ftp - starts an FTP session

  • open hostname - connects to the specified host

  • close - closes the connection (but not the FTP session!)
  • quit - terminates the FTP session

II. Browsing on a remote machine

  • dir - gives a full directory listing on the remote

  • dir test* - displays only files and directories whose
    name begins with "test..."

  • ls - same as dir, but provides a simplified listing of

III. Directories in FTP

  • pwd - prints the name of the current remote

  • cd remote-directory - changes working directory on remote

  • cd .. - moves up one level in the directory structure on
    the remote host

  • lcd directory - changes the default directory on local

IV. Types of files

  • binary - type this command at the FTP prompt to set binary
    mode before transferring binary files

  • For example, use binary mode with the following types of files:

    • SPSS System files

    • SAS Transport files

    • Stata Datasets

    • Graphics files (e.g., *.gif, *.jpg, *.bmp, etc.)

    • Microsoft Office documents (*.doc, *.xls, etc.)

  • ascii - type this command at the FTP prompt to set
    ASCII mode before transferring text files.

  • Use the ASCII mode with any of the following:

    • Raw Data (e.g. *.dat or *.txt, codebooks, or other plain
      text documents)

    • SPSS Portable files

    • HTML files

V. Transferring files

  • get test - copies file "test" from remote to local host
    (from current remote directory to current local directory)

  • mget test.* data.dbf - copies files beginning with "test"
    and the file named
    data.dbf from remote to local

  • put test - copies file "test" from local to remote
    You musth have write access to the remove host for this to

  • mput test.* data.dbf - copies files beginning with "test"
    and the file named
    data.dbf from local to remote host
  • quit - closes connection and terminates FTP

  • If a file name contains spaces (e.g. on your Windows system) you
    should type the file name in quotation marks " ",
    but it
    is strongly recommended to rename such files before FTPing them.

VI. Other Commands

  • get test " more" - displays file "test"
    To make sure
    you want a document, you can display it with the
    command and see the file screen by screen (using the space bar)
    BEFORE you
    get a file. To exit out of more
    , type q.

  • prompt - turns off prompting for individual files when
    using the mget or mput commands.

  • If you have mistyped your username or password, use the user
    command to re-login.

  • For a list of all FTP commands type ? at the ftp>

  • For a brief explanation of a command, type help, leave a
    space,and type the command itself.

Your Ad Here