
Note.
This tutorial intended for students at Morgan State University. Although it contains references that are specific to Morgan where the local machines on the engineering cluster are McCoy, Latimer and Washington, it may be of use to others.
Introduction.
FTP is a file transfer protocol that allows you to either get files from a remote site or to put files to a remote site.
I have divided this into two sections; host to host transfers such as transferring files from access.digex.net to your account on the engineering cluster and PC to host transfers.
Broad Overview.
Note that normally, you are connected to the cluster and are simply a terminal. The engineering cluster is thus the local system and the site you desire to get files from is the remote site. To fetch files from the remote, you use the "get" command. To send files to the remote, you "put" command.
An Example of Host to Host Transfer.
The following is treated as a specific example. Note that this is "anonymous" FTP. That is, you don't control an account on the distant machine. The distant machine has extended a privilege to you to fetch or "get" files. However, you can't write ("put ") files to the remote.
Connect via telnet to Latimer, McCoy or Washington. At the system prompt, enter;
ftp
This will provide you with an ftp> prompt. If you type a ? a rather overwhelming summary of commands will appear. For the moment, consider only the "open", "close" and "bye" commands. These are pretty obvious. You "open" an ftp connection to a remote site, you "close" the connection and to exit ftp, you use the "bye" command.
At the ftp prompt, enter;
open ftp.access.digex.net
Digex will prompt you for a user id. Use the word "anonymous". As most people can't reliably spell anonymous, the user id "ftp" is usually an acceptable alternative. Use your e-mail address as the password. For example; pha@eng.morgan.edu.
You are now logged on to Digex. Recognize that the engineering cluster is the local and Digex is the remote. If you do something wrong in the login process and get hung up, use the "close" command. This closes out the connection without exiting you fr om ftp. The "bye" command closes out the connection and exits you from ftp and you are back at the system prompt.
Changing Directories.
Again, we have the ftp prompt. At this point, you are in the root directory at Digex. At any time, you can ascertain where you are in the file structure by using the command;
pwd print working directory
You may view the files and directories in the current directory using the list command.
ls -l list in long format
[Note that commands are commands to the remote. However, you can issue commands to the local system by issuing commands to the local UNIX shell. For example;
!w just in case you are wondering who is on McCoy.
!pwd
!ls
]
After entering the command ls -l, you will receive something like this;
150 Opening ASCII mode data connection for /bin/ls.
total 4
dr-x--x--x 2 root staff 512 May 12 1995 bin
dr-x--x--x 2 root staff 512 Feb 27 1995 dev
dr-x--x--x 2 root staff 512 Feb 27 1995 etc
drwxr-xr-x 5 root 26 512 Nov 20 1995 pub
226 Transfer complete.
remote: -l
249 bytes received in 0.02 seconds (12 Kbytes/s)
A 'd' in the extreme left indicates, the file is a directory. The other information pertains to permissions. That is, who can read it. The only directory you can access is "pub".
You may proceed to change to the pub subdirectory;
cd pub
Note you are now in /pub. Enter the ls -l command. You can either continue to do this a step at a time, or with a single command;
cd /pub/access/pha/public_html
This happens to be my WWW directory.
If you now list;
ls -l
results in something like this.
drwxrwxr-x 2 16399 11 1536 Aug 16 08:05 6811 drwxrwxr-x 2 16399 11 1024 Aug 16 09:38 C -rw-r--r-- 1 16399 11 2946 Apr 9 05:51 FAQ1.html -rw-r--r-- 1 16399 11 560 Dec 24 1995 IEEELit.html -rw-r--r-- 1 16399 11 8033 Dec 24 1995 IEEERental.html -rw------- 1 16399 11 277 Sep 1 21:21 access.conf
Note that 6811 is a directory. The entries that begin with a dash are files.
Now,
cd sensors
ls -l
Note that you now are in /pub/access/pha/public_html/sensors
You should see a listing of files; gj.c, gj.h, etc. You can't view them, but you can "get" them back to your host and then read them.
Getting a File.
First, set the mode for the transfer using either the "b" or "a" commands; meaning binary or ASCII transmission. ASCII transfer is usually reserved for ASCII text files. All other files must be transferred using binary transfer. However, ASCII files ma y be transferred using the binary mode with some sacrifice in the speed of the transfer. If in doubt, always specify binary (b).
You may now transfer this file to your directory on the cluster by entering;
get gj.c
or get gj.c junk
In the first case, the file will appear in your directory under the same name. In the second, it will appear as file "junk".
Reviewing to this point, you logged on to the engineering cluster and went to ftp. You opened an ftp session to ftp.access.digex.net and logged in. You then went through the directories to /pub/access/pha/public_html/sensors. File gj.c interested you. So you "getted" it.
You can get each file in this manner. However another alternative is a multiple get;
mget
You will then be prompted in turn as to whether you desire to transfer each file.
Note that if you know exactly what file you are looking for you can avoid all of the directory jumping. After logging in, you can;
get /pub/access/pha/public_html/sensors/gj.c
You may now, quit ftp with the bye command.
From the system prompt; e.g., mccoy>, you can now check you have the file in your directory using the list (ls) command.
You can also view the files;
cat gj.c
or pico gj.c
As this file is several pages long, you probably will want to use the more filter;
cat gj.c | more
which will cause 25 lines to appear at a time. Use the space bar to advance to the next page.
Local Directory.
Recall that the local is the engineering cluster and the remote is Digex. The command "cd" changes the directory at the remote. You may desire to change the local directory.
For example, you may desire to fetch a gif image for your www directory. If you went into ftp from your home directory you are in /home/userid. You can do a local change directory;
lcd www
pwd
and then "get" or "mget". Don't forget to issue the "b" command prior to transferring non ASCII files.
Summary.
At this point, you have fetched the files from Digex and they are now on the engineering cluster. If you are working on your web page, this may be all you desire to do.
However, in this case, you really want these files on your floppy on your PC. We are only half way there.
PC to Host Transfer.
[Note. Many users transfer the files from their local account on the engineering cluster to their PC using such protocols as Z, X, Y or kermit protocols. In the Computer Engineering Lab, we use FTP, where the local is the PC you are using and the remote is the engineering cluster.]
Fetching Files.
From the Internet Group in Windows, click on the FTP icon. You will receive an ftp prompt. Open an ftp session to Mccoy;
open mccoy.eng.morgan.edu
In the previous discussion we used anonymous FTP. However, you all have accounts on the engineering cluster. Log in just as you would log in if you were telnetting to your account.
pwd
ls -l
The working directory should be your account; /home/userid. Using the ls -l, you should be able to see all of the directories and files in your root directory. Change directories as necessary.
Assume you want to get file gj.c on to your floppy. You can't do this!!!!!
get gj.c a:\gj.c
That is, get file gj.c and save it as a:\gj.c. The reason is, that it will try to save in the local directory, which might be c:\windows as a:\gj.c and a:\gj.c is not a legal DOS file name.
Therefore, prior to fetching any files, do a local change directory to the exact directory of where you want to save the remote file.
lcd a:\
Then, use the get or mget commands as described above.
Assume the file you desire to fetch from your account on the engineering cluster is named fast_food.html
If you try to;
get fast_food.html
it will fail for as the file name is not a legal DOS file name. Recall that in DOS, file names are limited to eight characters, and the extension is limited to three characters.
This will work;
get fast_food.html fst_food.htm
The file will be saved on your PC as "fst_food.htm".
Again, prior to transferring non ASCII files, remember to first change the mode to binary using the "binary" command.
Sending Files.
You may desire to transfer a file from your floppy to your engineering cluster account. This may be to make the file available to others, or you may wish to locally prepare your web pages using an ASCII editor on the PC and then upload them to your accou nt.
The procedure is the same. Open an FTP connection to mccoy.eng.morgan.edu, log in and change to the desired directory and then "put" the file.
Be sure to use the local change directory as the filename a:\sensors.htm is not a legal UNIX file name.
lcd a:\
put sensors.htm
Note that if this is a file for your web page, you will have to log in to mccoy using telnet and rename the file as a .html file.
Further, on all files that you wish to make available to others, remember to change the permissions on all directories to 755 and on all files to 644. For example, assume you have just logged in and at /home/userid.
chmod 755 www
cd www
chmod 644 sensors.html