Using FTP - An Example
The FTP program is the method by which you will turn in all of your homework assignments for this course, so it is important that you become familiar with this program.
Using FTP to submit assignments

FTP, or File Transfer Protocol, is a very simple program that can be used to transfer files between different computers. In CSCI 201, you will use FTP to transfer program solutions to your assignment drop-off directory stored on the UNCA CSCI file server.

Preparing to FTP

In order to work this example, you will need a file to ftp. You can get one by copying the following Java code and pasting it into your editing (gedit or wordpad) application.

//********************************************************************
//  Lincoln.java       Author: Lewis and Loftus
//
//  Demonstrates the basic structure of a Java application.
//********************************************************************

public class Lincoln
{
   //-----------------------------------------------------------------
   //  Prints a presidential quote.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      System.out.println ("A quote by Abraham Lincoln:");

      System.out.println ("Whatever you are, be a good one.");
   }
}
Now save the file in your csci/201/lab1 (or C:\Files\Lab1 if you're in Windows) directory under the name Lincoln.java. Be sure that you "click" through all three directories, csci, 201, and lab1, in the process of saving this file! Below is a linux screenshot as an example.
File Save example

Before you can transfer the file you must know the name of the directory that you will use when submitting your homework. This is your personal ftp directory and it should never be used by others. Your ftp directory name is like a password, it should be kept secret.

The original FTP program

The ftp program "speaks" the FTP protocol to a file server when it transfer files. The ftp program was one of the first two Internet applications. It is a text-oriented program that may seem a little quaint compared to today's graphic-oriented programs, like the ones you'll be writing in Java. We are going to use the original ftp program because it is the only FTP uploader that "ships" with every copy of Windows XX and Unix. So you should be able to follow this procedure at home or school, no matter what computer is sitting in front of you.

Transferring files to your drop-off directory

Remember, you are going to transfer a file (and later files) to your drop-off directory. You'll need to know three pieces of information to complete this task.

  1. The name of the PC directory containing the file. In our example, that is csci/201/lab1 (C:\Files\Lab1 for Windows).
  2. The name of the files to be transfered. We'll use Lincoln.java.
  3. The name of your drop-off directory. In our example, we'll use alincoln1809.

Your Assignment ...

Go back to your terminal window and type the command "ftp ftp.cs.unca.edu" (Windows users should press the Start button, then the Run menu button, and type "ftp ftp.cs.unca.edu" into the Open field and then hit enter).

pensacola% ftp ftp.cs.unca.edu
The FTP program should provide you with the following greeting:
Connected to ftp.cs.unca.edu.
220-Welcome to ftp.cs.unca.edu, Sat Aug 10 15:25:15 2002
220-
220 FTP server ready.
User (woodfin.cs.unca.edu:(none)):
You should type ftp followed by the Enter key at this initial user prompt.
Connected to ftp.cs.unca.edu.
220-Welcome to ftp.cs.unca.edu, Sat Aug 10 15:25:15 2002
220-
220 FTP server ready.
User (woodfin.cs.unca.edu:(none)): ftp
You will then be prompted for a password. Just type your email address as your password. Your email address is your bulldog user-id followed by @bulldog.unca.edu. For example, if your bulldog user-id is alincoln, your email address is alincoln@bulldog.unca.edu. Your email address will not be displayed when you type it.

If you have successfully connected, the ftp program should be at its command prompt: ftp> as shown below.

Connected to ftp.cs.unca.edu.
220-Welcome to ftp.cs.unca.edu, Sat Aug 10 15:25:15 2002
220-
220 FTP server ready.
User (woodfin.cs.unca.edu:(none)): ftp
331 Guest login ok, send your complete e-mail address as password.
Password:
230-This is the anonymous FTP server of the Department of Computer Science
230-at the University of North Carolina at Asheville.
230-
230-
230 Guest login ok, access restrictions apply.
ftp>
Your next step to do connect to the local directory where your files are now stored. This is done with the lcd (local change directory) command.
ftp> lcd csci/201/lab1     ( lcd C:\Files\Lab1   for Windows Users)
Local directory now /burnsville/users/YOURID/csci/201/lab1
Now you must change to your secret drop-off directory. This is done with the cd command. In our example the secret drop-off name is alincoln1809; consequently, the remote drop-off directory is pub/201/alincoln1809. In general, if your secret drop-off name is LOGINnnnn, your drop-off directory is pub/201/LOGINnnnn.
ftp> cd pub/201/alincoln1809
250-Abe Lincoln's CSCI 201 dropoff
250-
250 CWD command successful.
Transfer the file(s) that you want to submit by typing the put command followed by the file name. You should receive some indication of successful transmission. Remember, we are submitting Lincoln.java.
ftp> put Lincoln.java
200 PORT command successful.
150 Opening ASCII mode data connection for Lincoln.java.
226 Transfer complete.
652 bytes sent in 0.00272 seconds (2.3e+02 Kbytes/sec)
You can use the dir command to list your remote drop-off directory and the quit command to end your ftp session. Don't worry about the format of the dir command. Just make sure your submitted file is listed in the rightmost column.
ftp> dir
227 Entering Passive Mode (152,18,69,7,177,122)
150 Opening ASCII mode data connection for /bin/ls.
total 2
-rw-rw-r--   1 brock    csci201       31 Aug 10 14:21 .message
-rw-rw-rw-   1 bruce    csci201      632 Aug 10 14:42 Lincoln.java
226 Transfer complete.
ftp> quit