Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

Using anonymous FTP

From Higher Intellect Wiki
Jump to navigation Jump to search

Using "anonymous ftp" to get files from other Internet machines. Mark Moraes, University of Toronto

Anonymous ftp is a facility offered by many machines on the Internet. This permits you to log in with the ftp program with the user name 'anonymous' or the user name 'ftp'. When prompted for a password, type your e-mail address -- it's not necessary, but it's a courtesy for those sites that like to know who is making use of their facility. Be courteous.

Most ftp sites do not like people getting files from them during their working hours since they usually have other load on their systems -- avoid 9am-5pm in their time-zone.

Also bear in mind that countries are often connected by relatively low-bandwidth links, so please check local archive sites before you connect to some distant country to fetch something. If you think the item you want is popular, ask your local archive site sysadmin, who may be willing to set up a copy on the local archive.

Different archive sites have different forms of etiquette -- if you see a README or README.TXT file in the ftp directory, please read it.

Once you're connected to the remote site via ftp, you can look around and retrieve files. (Most anonymous ftp sites do not permit people to store files) The ftp program prompts you with

ftp>

and offers a few commands that are similar to Unix. "cd" changes your directory on the remote machine, "lcd" changes your directory on the local machine, "get" will get a file, etc. See the manual page for ftp (use the command "man ftp")

Typically, a directory called 'pub' is where the interesting things are stored. Some sites will have a file with a name like ls-lR, that contains a complete list of the files on that site. Otherwise, you can type ls -lR and get such a listing -- for some sites, this can take a LONG time. This doesn't work on some sites.

Usually, files are grouped in composite "archive" files, so you don't have to get many small files separately. The most common Unix archive file format for the Internet is tar, usually indicated by a ".tar" suffix in the file name. tar archives can be unpacked by running the tar command -- you may want to first do a 'tar t' on the file to see what it contains before unpacking it.

Occasionally, people use shell archives (with .shar or .sh suffixes) instead. These are Unix Bourne shell scripts, with files encapsulated in them. Be careful when unpacking shell archives since they have to be run through the Bourne shell to unpack them. The simplest way is to use the unshar command, if your system has one installed. Otherwise, you have to delete all the leading text with an editor and then run the rest of the text through "sh" o unpack the archive. Make sure you're in the directory you want the files in before you try unpacking the archive, since there's no good way to list the contents of an archive.

Files are often stored compressed -- for Unix, the most common form is the compress program, indicated by a .Z suffix on the file name.

Sometimes, people use programs like arc (indicated by a .ARC suffix), zoo (.ZOO), zip (.ZIP) or lharc (.LZH), which are combined archival and compression formats. (There are lots of other archive formats - talk to the systems staff if you encounter them and don't know how to deal with them) Macintosh archives are often in StuffIt format (.SIT). In each case, you need the relevant extraction program. Usually, the archive site will also have a copy of the extraction program for ftp. Finally, there's the "self-extracting" archive format, popular in the PC world -- they look like executable programs (.EXE) and when run, they unpack the files they contain.

When retrieving non-text files, you must use binary mode, otherwise the file gets messed up. To do this, use the 'binary' command. (It's safe to set this for text files if the other end is a Unix system, since Unix doesn't differentiate between text and binary file representation. If the site at the other end is non-Unix, you may need to use some other mode -- see the documents for that site and for ftp)

An example session follows -- the commands I typed are all underlined with a row of carets (^^^^) and are usually typed at the % or ftp> prompt.

% ftp ftp.cs.toronto.edu
  ^^^^^^^^^^^^^^^^^^^^^^
Connected to ftp.cs.toronto.edu.
220 neat.cs FTP server (Version 5.55 Tue Aug 8 22:48:27 EDT 1989) ready.
Name (ftp.cs.toronto.edu:moraes): anonymous
                                  ^^^^^^^^^
331 Guest login ok, send ident as password.
Password:[email protected]
         ^^^^^^^^^^^^^^^^^^^^^
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
ftp> dir
     ^^^
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 62
drwxr-xr-x  2 0        0             512 Nov 20  1988 bin
drwxr-xr-x 11 0        0            2048 Dec 29 00:45 pub
226 Transfer complete.
ftp> cd pub
     ^^^^^^
250 CWD command successful.
ftp> dir
     ^^^
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 4523
...
-rw-r--r--  1 0        0           51251 Sep 16 12:02 ssl.tar.Z
...
226 Transfer complete.
ftp> hash
     ^^^^
Hash mark printing on (1024 bytes/hash mark).
ftp> binary
     ^^^^^^
200 Type set to I.
ftp> get ssl.tar.Z
     ^^^^^^^^^^^^^
200 PORT command successful.
150 Opening BINARY mode data connection for ssl.tar.Z (51251 bytes).
##################################################
226 Transfer complete.
51251 bytes received in 0.94 seconds (53 Kbytes/s)
ftp> quit
     ^^^^
221 Goodbye.

Now, to see what ssl.tar.Z contains, I can use:

% uncompress < ssl.tar.Z | tar tvf -
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
drwxrwxr-x 7/0        0 Sep 16 11:58 1989 ssl/
-rw-r--r-- 7/0      301 Sep 16 11:58 1989 ssl/Makefile
-rw-r--r-- 7/0      240 Jun  2 01:08 1988 ssl/README
-rw-r--r-- 7/0    20642 Feb 26 21:43 1988 ssl/file.ssl
-rw-r--r-- 7/0     5241 Feb 21 15:25 1988 ssl/file.sst
-rw-r--r-- 7/0    56581 Sep 16 11:57 1989 ssl/ssl.c
-rw-r--r-- 7/0    20642 Feb 26 20:08 1988 ssl/ssl.ssl
-rw-r--r-- 7/0     5241 Feb 26 21:41 1988 ssl/ssl:sst.c
-rw-r--r-- 7/0     5395 Feb 26 21:41 1988 ssl/ssl:sst.h
-rw-r--r-- 7/0    12211 Mar 30 22:34 1988 ssl/sslskel.c
-rw-r--r-- 7/0      274 Feb 26 20:42 1988 ssl/sslskel.ssl
-rw-r--r-- 7/0       55 Feb 26 20:42 1988 ssl/sslskel.sst.c
-rw-r--r-- 7/0     1001 Feb 26 20:42 1988 ssl/sslskel.sst.h

To extract the files, I use

% uncompress < ssl.tar.Z | tar xvf -
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ssl/
ssl/Makefile
ssl/README
ssl/file.ssl
ssl/file.sst
ssl/ssl.c
ssl/ssl.ssl
ssl/ssl:sst.c
ssl/ssl:sst.h
ssl/sslskel.c
ssl/sslskel.ssl
ssl/sslskel.sst.c
ssl/sslskel.sst.h