@c -*-tex-*-
@node Anonymous FTP
@chapter Anonymous FTP

FTP (@dfn{File Transfer Protocol}) is the primary method of
transferring files over the Internet.  On many systems, it's also the
name of the program that implements the protocol. Given proper
permission, it's possible to copy a file from a computer in South
Africa to one in Los Angeles at very fast speeds (on the order of
5--10K per second).  This normally requires either a user id on both
systems or a special configuration set up by the system
administrator(s).

There is a good way around this restriction---the @dfn{anonymous FTP}
service.  It essentially will let anyone in the world have access to a
certain area of disk space in a non-threatening way.  With this,
people can make files publicly available with little hassle.  Some
systems have dedicated entire disks or even entire computers to
maintaining extensive archives of source code and information.  They
include @code{gatekeeper.dec.com} (Digital),
@code{wuarchive.wustl.edu} (Washington University in Saint Louis), and
@code{archive.cis.ohio-state.edu} (The Ohio State University).

The process involves the ``foreign'' user (someone not on the system
itself) creating an FTP connection and logging into the system as the
user @samp{anonymous}, with an arbitrary password:
@smallexample
Name (foo.site.com:you): anonymous
Password: @kbd{jm@@south.america.org}
@end smallexample

@noindent
Custom and netiquette dictate that people respond to the
@code{Password:} query with an email address so that the sites can
track the level of FTP usage, if they desire.  (@xref{Addresses} for
information on email addresses).

@cindex SLIP links, modem-based IP
The speed of the transfer depends on the speed of the underlying link.
A site that has a 9600bps SLIP connection will not get the same
throughput as a system with a 56k leased line (@pxref{The Physical
Connection}, for more on what kinds of connections can exist in a
network).  Also, the traffic of all other users on that link will
affect performance.  If there are thirty people all FTPing from one
site simultaneously, the load on the system (in addition to the
network connection) will degrade the overall throughput of the
transfer.

@section FTP Etiquette

Lest we forget, the Internet is there for people to do work.  People
using the network and the systems on it are doing so for a purpose,
whether it be research, development, whatever.  Any heavy activity
takes away from the overall performance of the network as a whole.

The effects of an FTP connection on a site and its link can vary; the
general rule of thumb is that any extra traffic created detracts from
the ability of that site's users to perform their tasks.  To help be
considerate of this, it's @emph{highly} recommended that FTP sessions
be held only after normal business hours for that site, preferably
late at night.  The possible effects of a large transfer will be less
destructive at 2 a.m@. than 2 p.m.  Also, remember that if it's past
dinner time in Maine, it's still early afternoon in California---think
in terms of the current time at the site that's being visited, not of
local time.

@section Basic Commands

While there have been many extensions to the various FTP clients out
there, there is a de facto ``standard'' set that everyone expects to
work.  For more specific information, read the manual for your
specific FTP program.  This section will only skim the bare minimum of
commands needed to operate an FTP session.

@subsection Creating the Connection

The actual command to use FTP will vary among operating systems; for
the sake of clarity, we'll use @samp{FTP} here, since it's the most
general form.

@cindex address, IP (Internet)
@cindex resolving
There are two ways to connect to a system---using its @dfn{hostname}
or its Internet number.  Using the hostname is usually preferred.
However, some sites aren't able to @dfn{resolve} hostnames properly,
and have no alternative.  We'll assume you're able to use hostnames
for simplicity's sake.  The form is

@c not smallexample!
@example
@kbd{ftp @var{somewhere.domain}}
@end example

@noindent
@xref{Domains} for help with reading and using domain names
(in the example below, @var{somewhere.domain} is @code{ftp.uu.net}).

@cindex UUNET
You must first know the name of the system you want to connect to.
We'll use @samp{ftp.uu.net} as an example.  On your system, type:
@smallexample
ftp ftp.uu.net
@end smallexample
@noindent (the actual syntax will vary depending on the type of system the
connection's being made from).  It will pause momentarily then respond
with the message
@smallexample
Connected to ftp.uu.net.
@end smallexample

@noindent
and an initial prompt will appear:

@smallexample
220 uunet FTP server (Version 5.100 Mon Feb 11 17:13:28 EST 1991) ready.
Name (ftp.uu.net:jm):
@end smallexample

@noindent
to which you should respond with @kbd{anonymous}:

@smallexample
220 uunet FTP server (Version 5.100 Mon Feb 11 17:13:28 EST 1991) ready.
Name (ftp.uu.net:jm): @kbd{anonymous}
@end smallexample

@noindent
The system will then prompt you for a password; as noted previously, a
good response is your email address:

@smallexample
331 Guest login ok, send ident as password.
Password: @var{jm@@south.america.org}
230 Guest login ok, access restrictions apply.
ftp>
@end smallexample

@noindent
The password itself will not echo.  This is to protect a user's
security when he or she is using a real account to FTP files between
machines.  Once you reach the @code{ftp>} prompt, you know you're
logged in and ready to go.

@c Notice the @samp{ftp.uu.net:joe} in the @code{Name:} prompt?  That's
@c another clue that anonymous FTP is special: FTP expects a normal user
@c accounts to be used for transfers.

@subsection @kbd{dir}
At the @samp{ftp>} prompt, you can type a number of commands to perform
various functions.  One example is @samp{dir}---it will list the files
in the current directory. Continuing the example from above:

@smallexample
@group
ftp> @kbd{dir}

200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 3116
drwxr-xr-x  2 7        21            512 Nov 21  1988 .forward
-rw-rw-r--  1 7        11              0 Jun 23  1988 .hushlogin
drwxrwxr-x  2 0        21            512 Jun  4  1990 Census
drwxrwxr-x  2 0        120           512 Jan  8 09:36 ClariNet
@center @dots{} @rm{etc etc} @dots{}
-rw-rw-r--  1 7        14          42390 May 20 02:24 newthisweek.Z
@center @dots{} @rm{etc etc} @dots{}
-rw-rw-r--  1 7        14        2018887 May 21 01:01 uumap.tar.Z
drwxrwxr-x  2 7        6            1024 May 11 10:58 uunet-info

226 Transfer complete.
5414 bytes received in 1.1 seconds (4.9 Kbytes/s)
ftp> 
@end group
@end smallexample

@noindent
The file @file{newthisweek.Z} was specifically included because we'll
be using it later.  Just for general information, it happens to be a
listing of all of the files added to UUNET's archives during the past
week.

The directory shown is on a machine running the Unix operating
system---the @kbd{dir} command will produce different results on other
operating systems (e.g. TOPS, VMS, et al.).  Learning to recognize
different formats will take some time.  After a few weeks of
traversing the Internet, it proves easier to see, for example, how
large a file is on an operating system you're otherwise not acquainted
with.

With many FTP implementations, it's also possible to take the output
of @kbd{dir} and put it into a file on the local system with
@smallexample
ftp> @kbd{dir n* @var{outfilename}}
@end smallexample

@noindent
the contents of which can then be read outside of the live FTP
connection; this is particularly useful for systems with very long
directories (like @code{ftp.uu.net}).  The above example would put the
names of every file that begins with an @samp{n} into the local file
@var{outfilename}.

@node cd
@subsection @kbd{cd}

At the beginning of an FTP session, the user is in a ``top-level''
directory.  Most things are in directories below it (e.g. @file{/pub}).  To
change the current directory, one uses the @kbd{cd} command.  To
change to the directory @file{pub}, for example, one would type

@smallexample
ftp> @kbd{cd pub}
@end smallexample

@noindent
which would elicit the response

@smallexample
250 CWD command successful.
@end smallexample

@noindent
Meaning the ``Change Working Directory'' command (@samp{cd}) worked
properly.  Moving ``up'' a directory is more system-specific---in Unix
use the command @samp{cd ..}, and in VMS, @samp{cd [-]}.

@node get and put
@subsection @kbd{get} and @kbd{put}

The actual transfer is performed with the @kbd{get} and @kbd{put}
commands.  To @dfn{get} a file from the remote computer to the local
system, the command takes the form:

@smallexample
ftp> @kbd{get} @var{filename}
@end smallexample

@noindent
where @var{filename} is the file on the remote system.  Again using
@code{ftp.uu.net} as an example, the file @file{newthisweek.Z} can be
retrieved with

@smallexample
@group
ftp> @kbd{get newthisweek.Z}
200 PORT command successful.
150 Opening ASCII mode data connection for newthisweek.Z (42390 bytes).
226 Transfer complete.
local: newthisweek.Z remote: newthisweek.Z
42553 bytes received in 6.9 seconds (6 Kbytes/s)
ftp>
@end group
@end smallexample

@noindent
The section below on using binary mode instead of
ASCII will describe why this particular choice will result in a
corrupt and subsequently unusable file.

If, for some reason, you want to save a file under a different name
(e.g. your system can only have 14-character filenames, or can only
have one dot in the name), you can specify what the local filename
should be by providing @kbd{get} with an additional argument
@smallexample
ftp> @kbd{get newthisweek.Z uunet-new}
@end smallexample

@noindent
which will place the contents of the file @file{newthisweek.Z} in
@file{uunet-new} on the local system.

The transfer works the other way, too.  The @kbd{put} command will
transfer a file from the local system to the remote system.  If the
permissions are set up for an FTP session to write to a remote
directory, a file can be sent with

@smallexample
ftp> @kbd{put filename}
@end smallexample

@noindent
As with @kbd{get}, @kbd{put} will take a third argument, letting you
specify a different name for the file on the remote system.

@subsubsection ASCII vs Binary

In the example above, the file @file{newthisweek.Z} was transferred,
but supposedly not correctly.  The reason is this: in a normal ASCII
transfer (the default), certain characters are translated between
systems, to help make text files more readable.  However, when
@dfn{binary} files (those containing non-ASCII characters) are
transferred, this translation should @emph{not} take place.  One
example is a binary program---a few changed characters can render it
completely useless.

To avoid this problem, it's possible to be in one of two modes---@dfn{ASCII}
or @dfn{binary}.  In binary mode, the file isn't translated in any way.
What's on the remote system is precisely what's received.  The
commands to go between the two modes are:

@smallexample
@group
ftp> @kbd{ascii}
200 Type set to A.   @emph{(Note the @strong{A}, which signifies ASCII mode.)}

ftp> @kbd{binary}
200 Type set to I.   @emph{(Set to @strong{I}mage format, for pure binary transfers.)}
@end group
@end smallexample

@noindent
Note that each command need only be done once to take effect; if the
user types @kbd{binary}, all transfers in that session are done in
binary mode (that is, unless @kbd{ascii} is typed later).

The transfer of @file{newthisweek.Z} will work if done as:

@smallexample
@group
ftp> @kbd{binary}
200 Type set to I.
ftp> @kbd{get newthisweek.Z}
200 PORT command successful.
150 Opening BINARY mode data connection for newthisweek.Z (42390 bytes).
226 Transfer complete.
local: newthisweek.Z remote: newthisweek.Z
42390 bytes received in 7.2 seconds (5.8 Kbytes/s)
@end group
@end smallexample

@quotation
@strong{Note:} The file size (42390) is different from that done
in ASCII mode (42553) bytes; and the number 42390 matches the one
in the listing of UUNET's top directory.  We can be relatively sure
that we've received the file without any problems.
@end quotation

@subsubsection @kbd{mget} and @kbd{mput}

The commands @kbd{mget} and @kbd{mput} allow for multiple file
transfers using wildcards to get several files, or a whole set of
files at once, rather than having to do it manually one by one.  For
example, to get all files that begin with the letter @samp{f}, one
would type

@smallexample
ftp> @kbd{mget f*}
@end smallexample

@noindent
Similarly, to put all of the local files that end with @code{.c}:

@smallexample
ftp> @kbd{mput *.c}
@end smallexample

Rather than reiterate what's been written a hundred times before,
consult a local manual for more information on wildcard matching
(every DOS manual, for example, has a section on it).

Normally, FTP assumes a user wants to be prompted for every file in a
@code{mget} or @code{mput} operation.  You'll often need to get a
whole set of files and not have each of them confirmed---you know
they're all right.  In that case, use the @code{prompt} command to
turn the queries off.

@smallexample
ftp> prompt
Interactive mode off.
@end smallexample

@noindent
Likewise, to turn it back on, the @kbd{prompt} command should simply
be issued again.

@c @section Joe Granrose's List
@c Monthly, Joe Granrose (@code{odin@@pilot.njin.net}) posts to Usenet
@c (@pxref{Usenet News}) an extensive list of sites offering anonymous FTP
@c service.  It's available in a number of ways:
@c @cindex FTPable Items
@c 
@c @itemize @bullet
@c @item
@c The Usenet groups @code{comp.misc} and @code{comp.sources.wanted}
@c 
@c @item
@c Anonymous FTP from @code{pilot.njin.net} [128.6.7.38], in
@c @file{/pub/ftp-list}.
@c 
@c @item
@c Write to @code{odin@@pilot.njin.net} with a @samp{Subject:} line of
@c @kbd{listserv-request} and a message body of @kbd{send help}.  Please don't bother
@c Joe with your requests---the server will provide you with the list.
@c @end itemize

@node archie,  , FTP, FTP
@section The @var{archie} Server
@cindex archie
@c archie is always in lowercase

A group of people at McGill University in Canada got together and created a
query system called @dfn{archie}.  It was originally formed to be a
quick and easy way to scan the offerings of the many anonymous FTP
sites that are maintained around the world.  As time progressed,
archie grew to include other valuable services as well.

The archie service is accessible through an interactive telnet
session, email queries, and command-line and X-window clients.  The
email responses can be used along with FTPmail servers for those not
on the Internet.  (@xref{FTP-by-Mail Servers}, for info on using
FTPmail servers.)

@subsection Using @var{archie} Today

Currently, archie tracks the contents of over 800 anonymous FTP
archive sites containing over a million files stored across the
Internet.  Collectively, these files represent well over 50 gigabytes
of information, with new entries being added daily.

The archie server automatically updates the listing information from
each site about once a month.  This avoids constantly updating the
databases, which could waste network resources, yet ensures that the
information on each site's holdings is reasonably up to date.

To access archie interactively, @code{telnet} to one of the existing
servers.@footnote{@xref{Telnet}, for notes on using the @code{telnet}
program.} They include

@display
  @code{archie.ans.net} (New York, USA)
  @code{archie.rutgers.edu} (New Jersey, USA)
  @code{archie.sura.net} (Maryland, USA)
  @code{archie.unl.edu} (Nebraska, USA)
  @code{archie.mcgill.ca} (the first Archie server, in Canada)
  @code{archie.funet.fi} (Finland)
  @code{archie.au} (Australia)
  @code{archie.doc.ic.ac.uk} (Great Britain)
@end display

@noindent
At the @code{login:} prompt of one of the servers, enter @samp{archie}
to log in.  A greeting will be displayed, detailing information about
ongoing work in the archie project; the user will be left at a
@samp{archie>} prompt, at which he may enter commands.  Using
@samp{help} will yield instructions on using the
@samp{prog} command to make queries, @samp{set} to control various
aspects of the server's operation, et al.  Type @samp{quit} at the
prompt to leave archie.  Typing the query @samp{prog vine.tar.Z} will
yield a list of the systems that offer the source to the X-windows
program @code{vine}; a piece of the information returned looks like:
@cindex help, with archie

@smallexample
@group
Host ftp.uu.net   (137.39.1.9)
Last updated 10:30  7 Jan 1992

    Location: /packages/X/contrib
      FILE      rw-r--r--     15548  Oct  8 20:29   vine.tar.Z

Host nic.funet.fi   (128.214.6.100)
Last updated 05:07  4 Jan 1992

    Location: /pub/X11/contrib
      FILE      rw-rw-r--     15548  Nov  8 03:25   vine.tar.Z
@end group
@end smallexample

@node archie Clients
@subsection @var{archie} Clients
@cindex archie

There are two main-stream archie clients, one called (naturally
enough) @samp{archie}, the other @samp{xarchie} (for X-Windows).  They
query the archie databases and yield a list of systems that have the
requested file(s) available for anonymous FTP, without requiring an
interactive session to the server.  For example, to find the same
information you tried with the server command @samp{prog}, you could type

@smallexample
% archie vine.tar.Z
Host athene.uni-paderborn.de
    Location: /local/X11/more_contrib
           FILE -rw-r--r--      18854  Nov 15 1990  vine.tar.Z

Host emx.utexas.edu
    Location: /pub/mnt/source/games
           FILE -rw-r--r--      12019  May  7 1988  vine.tar.Z

Host export.lcs.mit.edu
    Location: /contrib
           FILE -rw-r--r--      15548  Oct  9 00:29  vine.tar.Z
@end smallexample

Note that your system administrator may not have installed the archie
clients yet; the source is available on each of the archie servers, in
the directory @file{archie/clients}.

Using the X-windows client is much more intuitive---if it's installed,
just read its man page and give it a whirl.  It's essential for the
networked desktop.

@node Mailing archie
@subsection Mailing @var{archie}

Users limited to email connectivity to the Internet should send a
message to the address @samp{archie@@archie.mcgill.ca} with the single
word @kbd{help} in the body of the message.  An email message will be
returned explaining how to use the email archie server, along with the
details of using FTPmail.  Most of the commands offered by the telnet
interface can be used with the mail server.

@subsection The @var{whatis} database

In addition to offering access to anonymous FTP listings, archie also
permits access to the @var{whatis} description database.  It includes
the names and brief synopses for over 3,500 public domain software
packages, datasets and informational documents located on the
Internet.

Additional @var{whatis} databases are scheduled to be added in the
future. Planned offerings include listings for the names and locations
of online library catalog programs, the names of publicly accessible
electronic mailing lists, compilations of Frequently Asked Questions
lists, and archive sites for the most popular Usenet newsgroups.
Suggestions for additional descriptions or locations databases are
welcomed and should be sent to the archie developers at
@samp{archie-l@@cs.mcgill.ca}.
@cindex libraries

@vskip 0pt plus 1filll
@flushright
``Was f@"ur pl@"undern!''
(``What a place to plunder!'')
@b{Gebhard Leberecht Bl@"ucher}
@end flushright
