CSCI 201 -- Verifying file transfer

Here's some information to help you make sure you have placed your programs in the right place.

Getting the right tools

If you plan to transfer your files to the UNCA Computer Science server, you will need a file transfer program that uses SSH, the Secure Shell. The protocol to make this transfer is often called "sftp", for Secure FTP.

On a Linux computer, you can use the command line program sftp or you can try the very temperamental graphical application gFTP.

On a computer running Windows, we recommend WinSCP. The Information Technology group at Marlboro College has brief WinSCP tutorial for a bit more information. If you like a good command line interface, you can use the psftp program that is distributed with the PuTTY suite of secure connection programs.

On a Macintosh running OS X, you'll find the same beloved sftp command line program you can use with Linux. However, there are graphical programs available including the popular Fugu.

Finding your file

Undoubtedly, you've been asked to transfer a java file with a specific name, such as homeworkX.java in your assignment. If you've written your code using NetBeans 4.0, you've been working in a project stored in a special project directory such as /home/yourid/csci/201/homeworkX. In this case, your project directory has a subdirectory called src and you should find you homeworkX.java file located there. That is, your file should be /home/yourid/csci/201/homeworkX/src/homeworkX.java. If you are using a PC or Macintosh, you'll also find your file within the src folder of your project.

However, let's assume the worse. You can't even remember your project name or location. On a PC or Macintosh, you'll have to try one of their file search programs. On Linux you can use the find program.

Using find in Linux

Start up a terminal session and then type the following command, where homeworkX.java is the file you have "lost.".

[yourid@yourmach yourid] find . -type f -name homeworkX.java -print

If all goes well, the location of the file containing your program will be displayed. If find prints nothing, you are out of luck.

We're going to assume you completed the first lab and have a file called cruelworld.java in your directory. Use the find command to locate your file. If you have a problem, ask the lab insructor for help.

Copying your file on Linux

Let's assume you have been required to place cruelworld.java with your csci/201/HWN directory. Of course, you could use a file transfer program to do this. However, suppose your completed program is stored at the location hardtofind/lostpath/src/cruelworld.java. Then you can use the following two commands to place it in the right location. The first command creates the directory where the program is to be stored, and the second performs the actual file transfer.

[yourid@yourmach yourid] mkdir -p csci/201/HWN
[yourid@yourmach yourid] cp hardtofind/lostpath/src/cruelworld.java csci/201/HWN

Now go ahead and transfer your cruelworld.java program to the csci/201/HWN directory. In case of trouble, ask for help.

Making sure

Testing the transfer

Most of you are probably ready to go home, but suppose you really want to make sure you have the right file in the right place. Well, you can do that will two commands: One will attempt to compile the file, and the other will try to execute it.

You'll need to start a terminal session on one of the Computer Science computers to do these commands. If you're in Robinson 004, you already have one. If you are at "home" or in a UNCA computer lab, you'll need to use a secure shell client like PuTTY to make the connection. Connect to the candler.cs.unca.edu computer.

Compile and test

Compile with the following:

[yourid@yourmach yourid] javac csci/201/HWN/cruelworld.java

If this works, nothing will be printed. If you get any errors messages, you need to fix them.

Now try to execute your program with the following command. Notice the use of the -cp option to specify the classpath of your program.

[yourid@yourmach yourid] java -cp csci/201/HWN cruelworld

If your program produces the right output, you have mastered the dropoff.