CS120
Lab #1

Due at the end of lab. The purpose of this lab is to introduce you to the CS Department's systems, and to get you started learning Linux. The instructions below suggest a way for you to organize your programs - you can choose to do it this way for future labs as well (although you don't have to). The steps below will create a subdirectory for this lab, where you will do all your work. Then you will need to use an editor to create a C++ source file, then go through the steps necessary to compile (translate) and execute the program.

0) Introduce yourself to the students around you in lab. You should get to know your fellow students, as they can be a valuable resource (an "extra set of eyes") when you have programming problems. Also, you will get a chance to work together on later labs and assignments.

1) Use putty to log into wormulon.cs.uidaho.edu. You will use your VandalWeb Username and password to log on. If you have any trouble doing this, be sure to ask the TA for help.

2) Use the mkdir command (short for "make directory") to create a directory called lab1 (mkdir lab1).

3) Use the cd command (short for change directory) to move into the new lab1 directory.

Note: if you expect to take additional CS courses in future, you may wish to first make a directory cs120 to hold all your work for this course, cd into it, and then perform steps #2 and #3 above within the cs120 subdirectory.

4) Use an editor such as nano, vi or emacs to create a file called nim.cpp and write the NIM program in the file. (If you have already created the NIM program somewhere else you may use the cp command (the copy command) to copy the program into your labs directory.) Include a block of comments at the beginning of the program (or add to the existing block) that lists your name, section number, date, and the assignment number.

5) Use g++ to compile the NIM program (g++ nim.cpp). If you typed the program perfectly, this step will create a file called a.out. It is quite likely that you made an error - if so, the compiler will probably generate some error messages. Welcome to the world of programming! Try to use the error messages, and your inspection of the Nim program you typed in, to try to find the error. If the mistake you made is not obvious, or the error message doesn't help to find the error, ask the TA (or your neighbor) for help in figuring it out. Once you find the problem, re-edit your program and try compiling again. Once your program is error-free, you can then execute the program by typing ./a.out (notice the ./ on the front to run the program).

6) Once the NIM program is working properly, use the script command to create a printable output file. The command script lab1output will create a file called lab1output which will contain all the commands and output that you type from this point onward (until you type exit).

7) Once the script is started run NIM and play a sample game, then use the commands pwd and ls to show the current directory and its contents. Finally, use the exit command to end the script.

8) You should now have a file called nim.cpp containing the NIM program and a file called lab1output containing a 'transcript' of a NIM game and the pwd and ls commands. Print both files (using the lpr command) and turn them in to your TA.

Note: this first lab is intentionally easy, but please underestimate neither its importance, nor the level of effort that will be required of future labs. It would be good to spend some extra time reading about UNIX commands and asking questions. Until I find one that's better, feel invited to checkout OSU's UNIX tutorial