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.
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."); } }
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 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.
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.
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
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)):
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
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>
ftp> lcd csci/201/lab1 ( lcd C:\Files\Lab1 for Windows Users) Local directory now /burnsville/users/YOURID/csci/201/lab1
ftp> cd pub/201/alincoln1809
250-Abe Lincoln's CSCI 201 dropoff
250-
250 CWD command successful.
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)
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