Welcome to the first lab in the CS 143 course. For this course, you are going to need a SEAS account. If you do not have a SEAS account, please talk to the front desk to get one set up ASAP.
On your desktop, there is a program called Secure Shell Client. This program allows you to ssh into the SEAS server in order to work on your files. This program is also available for download from the GWU Help Desk Homepage, so you can work from anywhere with an internet connection. Another such program is called PuTTY. For this course, you should do all your work through one of these two programs, directly on the server. We will cover how to do this later.
The server you will be working on this semester is referred to as hobbes. The Host Name is hobbes.seas.gwu.edu. In the Secure Shell Client, click Quick Connect, enter in this name into the host name section, and put your SEAS user name in for the user name. Clicking connect will prompt you for your SEAS password.
NOTE: When you first log in, you will be in the ksh shell. This shell is not very user friendly. Type bash into the command line to change to the bash shell. This shell is more user friendly, allowing you to press the up arrow to reference previously typed commands.
Please review the list of commands above. They will be used throughout the semester. Note that the directory you start in when you log into hobbes is referred to as your home directory.
In Unix, there are two types of paths: Relative and Absolute. A relative
path is a path that relies on your current location in the Unix directory
structure. An absolute path is a path that is the same from any location
in the directory structure. An absolute path always starts from the root (/)
directory. For example, if I am in my home directory, the absolute path
to my cs143 directory is
while the relative path to it is just
There are a few special path modifiers you can use. One is ~ which stands for the home directory. Another is .. which stands for the directory above the current directory in the file system tree
Files and directories in Unix are protected by three sets of permission
descriptors. You can view these using the
Note: Compiling a program that consists of multiple files is more complicated than this. We will cover how to do such when necessary.
C runtime errors are usually not too descriptive. Often, you will just get a Segmentation Fault. This error occurs when a program attempts to access memory that it does not have access to, or is accessing it invalidly. Thankfully, there is a runtime environment that can assist in determining what caused the error.
First, GCC must be instructed to instrument the code to be run in the debugger. We do this by using the -g flag during compilation. As an example, consider the compiler code that has been provided for use in Exercise 1:gcc -o ex1 ex1test.c ex1.c uniform.c -lm
To be able to use the debugger, we just add the -g flag to the command:gcc -g -o ex1 ex1test.c ex1.c uniform.c -lm
To use GDB, just execute the following command:gdb <exe>
Where <exe> is your executable. This will bring up the GDB command prompt. typing run will execute your code. When it encounters an error, it will display the function call stack (and usually a line number) for you to investigate further. Type q to exit the debugger. GDB is more powerful than this, however. For more information about GDB, go to the GDB Reference for more information.
In your home directory create two directories (see the above link to view
commands), a cs143 directory, and a submit directory. We need
to alter the permissions of your submit directory so that we will be able to
access your files. We will use the chmod command.
chmod a+rx submit
This gives everyone read and execute privileges to your submit directory. permissions for the submit directory should be drwxr-xr-x.
All programming assignments will be turned in using Dr. Simha's
Please email me your 8 character
alpha-numeric encryption key as soon as possible. Be mindful of the
Naming Conventions listed at the bottom of the linked page. If your files are
not listed correctly in your submit directory, I will be unable to grade your
work. Also, make sure that you are using the correct directories as listed
in the Submission Script tutorial. Failure to do so will result in a loss of
points on the assignment.
To complete this tutorial,
you will submit the text file of your answers to this lab. I will check these
this weekend, and send an email to those who have successfully submitted.
submit your work as
For example, I would submit as cssmith0.
In order to ease the pressure on you, I have devised a way for you to quickly and easily submit your programs, utilizing Dr. Simha's submit script. In your home directory, open a new document called SUBMIT. On the first line of the file, type #!/bin/bash. This will allow us to use bash scripting to create an easy submit script. Next, place the following lines of code below the previous line.jar cvf $1.jar $1
Save this file, and then give eXecute privileges to only yourself (U, Ask me if you need help). Now, once your have finished programming your assignment, you can simply call the submit script to submit. For example, if I were to submit our lab0 example, I would do the following:cd ~/cs143
Make sure that you receive a time stamp during your submission process, otherwise something has gone wrong.