DISC Logo

Using FTP and Anonymous FTP

Table of Contents

  1. Introduction

  2. FTP Syntax

  3. Anonymous FTP

  4. Using GZIP.EXE and PKUNZIP.EXE to Uncompress DPLS Data


Introduction

What is FTP?
FTP (File Transfer Protocol) is a utility for transferring files between host computers on the Internet. FTP is preferred for file transport because of its generality, speed, and ease of use. Most computer platforms (DOS, Unix, etc) allow you to run FTP.

What is this Document?
This technical note explains how to transfer (or "to FTP") ASCII and binary files between a local host (your computer) and a remote host (some other computer), such as the DPLS computer.

TCP/IP
FTP is part of the Transmission Control Protocol (TCP) and Internet Protocol (IP) suite of programs. TCP/IP is a large collection of computer standards used to organize and execute data that moves through the Internet. The University of Wisconsin-Madison campus Ethernet backbone uses TCP/IP, and includes all DPLS hosts and nearly all other departmental systems.

The Basics
FTP works interactively, which means that the user types in commands and FTP responds with immediate feedback. An FTP session consists of four basic steps:

  1. To invoke the FTP program;
  2. To access the remote host from which files are to be read or to which files are to be written;
  3. To identify the user id on the remote host, and provide the password to the user id; and
  4. To provide a set of commands to access directories at the local and remote hosts, to view files, define the type of files to be transferred, and to transfer the files. While conventions may differ slightly among different operating systems, the basic command structure remains the same.

FTP SYNTAX

While there are a variety of FTP commands, the following are the most common (but check your own system for which commands are available):

  • ftp - starts the FTP session

Browsing on a remote machine

  • dir - gives a full directory listing on the remote machine
  • dir da* - displays only files and directories whose name begins with the string da
  • ls - same as dir, but provides a simplified listing of filenames

Directories in FTP

  • pwd - prints the name of the current remote directory
  • cd - remote-directory - change working directory on remote host. Note that some systems are case-sensitive!
  • cd .. - moves up one level in the directory structure on the remote host
  • lcd directory - changes the default directory on local host

Types of files

  • binary - to enter binary mode for transferring binary files
  • ascii - to enter ASCII mode for transferring text files

Transferring files

  • get GSS7294.DAT - copies file from remote to local host. Note that some systems are case-sensitive!
  • mget GSS*.* - copies files beginning with "GSS" from remote to local host
  • put GSS.DAT - copies file GSS.DAT from local to remote host
  • prompt - toggles prompting switch (Y/N) for individual file transfers
  • quit - closes connection and terminates FTP session

Other Commands

  • ! - usually returns to local shell; type exit to go back to remote shell
  • get README "|more" - displays file "README" on your screen (as opposed to downloading to your disk)
    To make sure you want a document, you can display it with the
    more command and see the file screen by screen (using the space bar) BEFORE you get a file. To exit out of more , type q.
  • For a list of all FTP commands type ? at the ftp> prompt.
  • For a brief explanation of a command, type help, leave a space, and type the command itself.

Anonymous FTP

Anonymous FTP allows users to read files from (and in some cases write to) special directories residing on remote hosts. There are several reasons as to why such directories are created. Two of the most common are: 1) distribution of publicly available software; and 2) access to archival records of discussion groups. An example of how to access one such group is provided below.

Anonymous FTP is useful because it allows all users who do not have a login name or a password to access and copy most files. This type of FTP has a special login name: "anonymous". When connecting to a remote host you give "anonymous" as your login name. As for the password, FTP accepts any string, but the managers of the server prefer the electronic mail address of the user to keep track of users. After signing is as "anonymous", you can access the relevant directories and "get" those files that are permitted to the anonymous FTPers. The conventions illustrated in previous examples hold. The following example shows how to FTP to the server jse.sta.ncsu.edu.


 $ ftp jse.stat.ncsu.edu                #start FTP connection to remote host
 Connected to jse.stat.ncsu.edu.
 220 jse JSE Information Service (Version 6.19 Tue Jul 13 15:22:02 EDT
 1993) ready.
 Name (jse.stat.ncsu.edu:pitruzz): anonymous            enter logon id
 331 Guest login ok, send e-mail address as password.
 Begin your password entry with a - (dash) to suppress the helpful messages.
 Password:abc12@foo.edu                         type your email adress
 230-Welcome!
 230-This is the Journal of Statistics Education Information Service.
 230-If you have problems, try using a dash (-) as the first character
 230-of your password -- this will turn off continuation messages that may
 230-be confusing your ftp program.
 230-If you experience unusual problems, please report them via e-mail
 230-Please note that all transactions done through anonymous ftp are
 230-recorded for reporting and accounting purposes.
 230 Guest login ok, access restrictions apply.
 ftp> dir                               check remote general directory
 200 PORT command successful.
 150 Opening ASCII mode data connection for /bin/ls.
 total 31
 dr-xrwxr-x  2 0        10            512 Jul 16 15:21 .cap
 -rw-r--r--  1 0        1           12550 Jul 27 14:15 access.methods
 -rw-r--r--  1 0        10           1203 Jul 26 14:03 readme
 dr-xrwxr-x  9 0        10            512 Jul 16 15:57 software
 226 Transfer complete.
 891 bytes received in 0.74 seconds (1.2 Kbytes/s)
 ftp> cd software                       change to sub-directory software
 250-Please read the file readme
 250-  it was last modified on Fri Jul 16 11:49:41 1993 - 27 days ago
 250 CWD command successful.
 ftp> dir                               check sub-directory software
 200 PORT command successful.
 150 Opening ASCII mode data connection for /bin/ls.
 total 19
 drwxrwxr-x  3 20       10            512 Jul 16 15:57 info
 -rw-r--r--  1 20       10          11526 Jul 16 15:49 readme
 drwxrwxr-x  3 20       10           1024 Jul 16 15:05 sas
 226 Transfer complete.
 499 bytes received in 0.19 seconds (2.6 Kbytes/s)
 ftp> cd sas                            change to sub-directory sas
 250-Please read the file readme
 250-  it was last modified on Fri Jul 16 11:05:43 1993 - 27 days ago
 250 CWD command successful.
 ftp> dir                               check sub-directory sas
 200 PORT command successful.
 150 Opening ASCII mode data connection for /bin/ls.
 total 2652
 drwxr-xr-x  2 20       10            512 Jul 16 15:06 .cap
 -rw-r--r--  1 20       10          96924 Jul 16 15:05 sasusage.pak
 226 Transfer complete.
 2678 bytes received in 1.2 seconds (2.1 Kbytes/s)
 ftp> get sasusage.pak                 get file sasusage.pak
 200 PORT command successful.
 150 Opening ASCII mode data connection for sasusage.pak (75940 bytes).
 226 Transfer complete.
 local: sasusage.pak remote: sasusage.pak
 77446 bytes received in 19 seconds (4 Kbytes/s)
 ftp> quit                              quit to local UNIX host
 421 Timeout (900 seconds): closing control connection.
 $

Using GZIP.EXE and PKUNZIP.EXE to Uncompress DPLS Data

Most of our data are stored in what is called GZIP (gnuzip) and PKZIP (pkunzip) format. PKZIP is a standard in the PC world for compressing files. GZIP is a method of compression (similar to PKZIP) but originally designed for UNIX systems. These files (usually identified with a .gz or .z file suffix if GZIP, .zip if PKZIP) need to be downloaded AS BINARY (e.g., type bin at the ftp prompt) and then uncompressed for use.

  • On a P.C. you must download the file gzip.exe and use it via the DOS command to uncompress GZIP files.
  • Once you have downloaded gzip.exe, type gzip -h to generate command-line instructions.
  • In short, to decompress a file named foo.gz you type the following:
  • gzip -d foo.gz
  • WARNING! if your source files have three part filenames instead of the more normal two (e.g., foo.87.gz instead of foo.gz) -- the ICPSR does this quite frequently -- you will need to rename them to have only two parts before using gzip (which is DOS-based program!). Alternatively, you can download Winzip.
  • Be aware that gzip can compress a file by up to 80%. Examine all related documentation carefully to make sure that you have enough diskspace to decompress the file. It is also wise to move the gzip files into a separate directory to avoid writing over any files you already have on disk.
  • If your files are ZIP, you can download pkunzip.exe and use it via the DOS command to uncompress your files.
  • Once you've downloaded it, you can type PKUNZIP at the DOS prompt to get the help screen.
  • To uncompress the file foo.zip type the following:
  • pkunzip -d foo.zip
  • Alternatively, you can download Winzip. As with GZIP, make sure you have enough diskspace to uncompress your file, and make a separate directory to avoid writing over any files you already have on disk.


Last updated 16 January, 2002.

©2008 Data and Information Services Center, University of Wisconsin-Madison.
If you have trouble accessing this page, please contact disc@mailplus.wisc.edu.