September 9, 2003
The purpose of today's lab is to introduce you to Windows, Beowulf (the
UNIX machine we will be running C programs on), emacs (text editor), pine
(email) and Internet Explorer(web browser).
Each lab will be attended by a teaching assistant (and by me). The
teaching assistant for the 1:00 lab is Oluwatoyin Abogan, and the teaching
assistant for the 3:00 lab is Asten Buckles.
Log on to the Smith network. Sit down at a PC. Use the top button on the system unit to turn on the PC (if it isn't already on).A login window should pop up. Log in to the Bass server, using your Smith Netware account (see the instructor if you don't have an account). Then log in to the Windows workstation using username "student" and no password.
Connect to Beowulf. Click on the SSH Secure Shell Client icon. In the SSH window, hit the enter key. In the pop-up window, type Beowulf.csc for the host name, and the account name that you receive in lab today( 111a-xx). Use the password that you received with the account name. You should see Beowulf's prompt -- a short line ending with $. If you don't, type ctrl-C.
Change your password. The first thing you should do is to change your password. Enter the command passwd and, when asked, type in the password that was given to you. You will then be asked for a new password. Choose one carefully -- you will be required to have a password that uses both upper and lower case, and also some digits or maybe punctuation. Also, be sure to write down this password! When you are asked to verify, type in the new password a second time. If all went successfully, Beowulf's prompt will reappear. Remember to use this new password the next time you log in!
Create a file with the text editor emacs. You are now ready to create a C program in a file called graduation.c, You will do this using emacs, the editor we will be using in this course. Type emacs graduation.c When emacs pops up, enter the following C program, exactly as it appears here (don't worry if you don't understand the program -- you'll be learning about C programs in class):
/* File: Graduation.c * Description: This program asks the user for the year in which she will graduate and then tells her how many months remain untilher graduation. As a friendly touch, the program asks for
the user's initials and then uses her initials in its output. * Author: Merrie Bergmann * Date: September 9, 2003*/
#include <stdio.h>
#define this_year 2003#define extra_months 8#define months_in_year 12int main (void)
{ int graduation_year, num_months; char first_initial, last_initial; /* Print a welcome and get information from the user */ printf ("\n*** Welcome to the Smith College graduation program! ***\n\n"); printf ("What are your first and last initials (e.g., MB)? "); scanf ("%c%c", &first_initial, &last_initial); printf ("What year do you graduate (e.g.,2002)? "); scanf ("%d", &graduation_year); /* Compute number of months til graduation */ num_months = (graduation_year - this_year - 1) * months_in_year + extra_months; /* Print the result and say goodbye */ printf ("\nWell, %c%c, you will graduate in %d months!\n\n",first_initial, last_initial, num_months);
printf ("Goodbye, and thank you for using this program.\n\n");}
Be sure to press the Enter key at the end of each line. (You will lose points on your projects if you don't press the Enter key at the end of each line. The \ character appearing at the end of a line in Emacs is a warning that you did not press the Enter key.) When you are done, you may leave emacs by entering ctrl-x ctrl-c. Emacs will ask you whether you want to save your file. ENTER y!
If
you need to make changes while using emacs, here are some special keys that you
can use. You should also consult the emacs handout that is available in today's
lab.
Cursor keys (arrows) : to move around in the file
Backspace key : delete the character to the left of the cursor
ctrl-a (i.e., simultaneously press the control ("ctrl") and "a" keys) : move cursor to beginning of line
ctrl-e : move cursor to end of line
ctrl-k : delete line
ctrl-x [ (i.e., simultaneously press the control and x keys and then press the "[" key) : move cursor to beginning of file
ctrl-x ] : move cursor to end of file
ctrl-v : scroll up one screenful
esc v : scroll down one screenful
If
you want to go to a particular line number, type esc x, and
then goto-line.
You will be asked for the line number.
After leaving emacs, if you want to erase the emacs stuff that still appears on the screen, type clear after Beowulf's $ prompt.
Now enter ls. This means: list the files that are in my directory. You should see a file called graduation.c.
Compile and run your C program. You can compile your program (a process that translates C into machine language) by typing gcc graduation.c. If you get ERROR messages, then you made a mistake when you typed the file. In this case, go back to emacs and compare the file with what I handed out, and correct your typos.
When compilation is complete, type ls again. You will see a file called a.out. This is the executable file that the compiler creates. To run the program, type a.out at Beowulf's prompt. As the program runs, answer the questions on the screen. When the program is done running, you will see Beowulf's prompt on the screen once again.
Use Pine to send a copy of the program to yourself. Pine is the email program which we will use on Beowulf. You may consult the Pine handout, which you should pick up during this lab, for detailed information on using Pine. For now, we will just go through some basic operations, sending a file to yourself. Type pine, and then E to remove the introductory message. Now press C (for "compose message"). After To: type your Beowulf account name and press Enter. Press Enter after Cc: and Fcc:, and type graduation.c after Attchmnt:. Type in a subject like C Program on the Subject: line. In the area where your message goes, type a brief message to yourself and then press ctrl-X to send the mail message. Answer Y to Send Message? Then quit Pine by entering Q. You should now have the $ prompt back on your screen.
To read the message that you just sent to yourself, run Pine again. At the bottom of the screen, you should see Folder "INBOX" opened with 1 message. Press I (for Message Index). You should now see the message header highlighted -- press ENTER to see the message. You will see the message text on the screen. To get the attached program, enter V and then press ENTER again. Type S graduation.c to save the file in your account - and when asked whether to append or overwrite, choose O. (This replaces the file rather than adding to it.) Press < three times to get back to the message index. You can delete this mail message by typing D when the header is highlighted. Then quit Pine with Q.
When you are working on projects and need help, you can send your program to me (account 111a) using the above instructions, along with your questions in the message area.
Change your finger information. The Pine program added "111a Student" to your account name just now when you sent email. This is information provided by the finger program. At Beowulf's prompt, type finger. You will see a list of the people who are currently logged in, under the header
Login Name TTY Idle Login Time Office Phone
Find your own account, and you will again see "111a student". You can change this name by typing chfn and following the instructions. When you are done, run finger again to confirm that your name has been changed. The new name is the one that pine will attach to your email from now on.
Close the Beowulf session. You should now log off of Beowulf: type logout at Beowulf's prompt. Then close the SSH window by either pressing the X in the upper righthand corner of the window or choosing Exit from the File menu.
Use Internet Explorer to find the web pages for this course. Connect to the the World Wide Web with the Netscape Communicator web browser: double-click the Netscape Communicator icon on the desktop, or alternatively, press on the Start button, and select Programs/Internet Tools/Netscape.
After Internet Explorer pops up, type cs.smith.edu in the "Address" box. This will take you to the Computer Science Department's home page.
From
here, you should follow the link for Courses, then the link for Computer
Science I (Fall 03). Find and click on the link for Lab 1, and you'll
see the online copy of this handout. Return to the Syllabus page by pressing
the Back button at the top of the screen. Click on the link for Homework
1, and you'll see the homework that has been distributed today. In the
future, if you need a lab or homework assignment, you can use these links to
get one.
There is one more web site you should look at; it is at http://webopedia.internet.com. This is a very useful online dictionary and resource for computer terminology. For example, enter RAM in the Keyword Search box, and see what pops up. Remember this resource when you need to have a computer term defined!
Finally, exit Internet Explorer.
Log off of the network. Press the Start button, and choose Log Off Student.
There is nothing to submit for labs in this course; their purpose is to prepare you for the weekly homework. You are now ready to do Homework #1, which is attached to this lab. You can start right now if time remains, or leave to do something else. The homework is due next Tuesday. You may do your homeworks in EGR 203 when it is available, or Burton B01 and B17 (in Burton basement), or from any other PC or MAC that has a ssh program. You can download a copy of ssh onto your own PC or Mac from the Science Center website: www.science.smith.edu. Click on the Facilities/Resources link, then the Document Server link, then the Download Files Collection link. The PC program is SSH Windows Client, and the Mac program is Mac SSH.
Teaching Assistants for this course will be in EGR 203 for help sessions as follows:
|
Thursday |
7-9 pm |
Liz Antoske, Lin Qian |
|
Friday |
7-9 pm |
Tam Le, Emily Garvey |
|
Sunday |
7-9 pm |
Oluwatoyin Abogan, Liz Antoske, Emily Garvey |
|
Monday |
7-9 pm |
Oluwatoyin Abogan, Emily Garvey |