CSCI-203 Lab 1 Fall 2002



Objectives

  1. Become familiar with the Common Desktop Environment (CDE).

  2. Learn a few UNIX commands.

  3. Watch the Itty Bitty Machine do its thing.

  4. Become familiar with emacs as a tool for editing files.

  5. Learn to ask questions.

Relax, your lab assignments are designed to be interesting as well as informative and, generally, doable within a two hour period.

References: Beginner's Guide to Programming on the Suns: Various sections.

Introduction

Welcome to what is probably your first session with a Sun workstation.

We have had to design this first lab for students with various levels of computer sophistication. You may have a lot of in depth experience with computers, or you may always use one in a very simple straightforward way; most likely you are somewhere in the middle. This lab was designed with the underlying assumption that you have used a computer, but may not have investigated many of the features which are available -- moving windows around, changing their size, entering commands in an system window, configuring the appearance of your ``workspace''. We will touch on these issues in this tutorial, and some others as well.

If you have a lot of previous computer related experience you might be able to move through the tutorial pretty quickly. If you don't have that level of experience we have tried to make the lab doable in 2 hours or less. Remember, if you get stuck, just raise your hand (it won't hurt) and help will be there shortly. It might also help to know that the principles behind the Sun computing environment are very similar to those behind the PC and Mac environments also.

If you did not bring your copy of Beginner's Guide to Programming on the Suns, or simply -- we will refer to it as ``The Guide'' -- introduce yourself to a neighbor who did and ask if they mind sharing. The Guide was written specifically for new system users and is referred to often herein. If you have trouble finding a friend your professor or TA will assist you. This lab will be difficult to complete without The Guide at your side.

Logging In

Before you can do anything useful with the machine in front of you, you must ``login'' as is detailed in The Guide, sections 2.1 and 2.2. Read through sections 2.1 through 2.2.1 now, then go ahead and enter your account name and password as described. If things don't work quite as indicated ask for assistance. You should be able to login properly by following the instructions in 2.2.1.

The next relevant section will be 2.3.

The CDE Environment

Once you have logged in the working environment should appear -- it will consist of a blue background, sometimes called the workspace, and a control panel at the bottom of the screen. The control panel consists of three parts: the two sides contain icons representing various functions to be performed while the middle section shows some basic controls as well as buttons for switching among four possible workspaces. You will probably always work in the first workspace, so don't worry about the others. Finally, you should see an ``arrow'' on the screen somewhere -- the mouse pointer, which you expect with a window-based system such as this.

If the screen doesn't appear as described something is amiss. Try logging in again; if that doesn't help, raise your hand and someone will help.

Windows and Menus

The window environment of the CDE is patterned after the MS Windows functionality. If you are familiar with that then the discussion below should sound familiar.

With the mouse pointer on the blue background press and hold down the right mouse button. This will activate a menu of options. Still pressing the mouse button, slide the pointer down the menu until you come to the Hosts entry. When you hit that entry another menu should open up -- slide the pointer to the right until it is over the new menu and slide down until you reach the entry Terminal Console -- then release the button. This action should cause a ``window'' to appear on the background. The window has four sides with a wider top border called the title bar. You'll notice that the title bar reads ``Console''.

At either end of the title bar are special icons. If you click on the ``dot'' icon at the right end the window will disappear and a smaller box will appear. This is that same window in ``icon'' or ``iconified'' form. Click anywhere on the icon and you will see that the icon disappears and the window reappears. If you click on the ``box'' icon at the far right end of the title bar the window will expand to fill the entire screen -- click again on that same box icon and the window returns to its original shape. Now click on the ``bar'' icon at the left end of the title bar; a menu should appear; the same menu appears if you click the right button anywhere on the title bar.

You can change the dimensions of a window. If you put the pointer over any one of the four corners notice that the shape of the pointer changes. If you click and drag, the window size changes. One-directional change can be accomplished similarly by placing the pointer on any edge of the window. Notice again that the shape of the pointer changes and clicking and dragging causes the change.

Finally, you can change the position of the window by clicking (the left button!) in the center part of the title bar and dragging. Notice that the window doesn't change shape, only position.

Now click on the ``bar'' icon on the left of the console window's title bar and select the ``Close'' option from the menu. The window disappears.

Focus

Once again open a console window by going through the same steps as before, starting with the background menu. Now follow the same procedure except when you have the ``Hosts'' menu, select the Terminal option; this will open up a new window -- notice that it's title bar is structured similarly to the console window but the title is different. Using techniques from the previous section, fix both windows so that they do not overlap.

Now when you look at the windows you should notice that one of them has a reddish border and the other has a grayish border. If you type a couple of keys notice that the characters show up in the window with the reddish border. Now click in the title bar of the other window. You should see the two windows swap border colors. Now if you type the characters appear in the other window; this is even true if you move the mouse button out of the window and onto the background. The window in which the characters appear is said to ``have the focus'' and this condition is marked by the reddish border. You change the focus by clicking in the title bar of the window. Actually, you can change focus by clicking just about anywhere in the new window.

Configuring the Workspace

The window you now have open are useful enough that you should always have then available. However, the console window should usually be iconified. This is because it is usually used to display system messages and not for system interaction. At this point iconify the console window. Position the terminal window as you wish and then go back to the workspace menu. This time slide down to the Applications menu entry then slide over to the new menu and select the entry Clock. A window will appear which has a clock face. This window can be resized and repositioned as you wish. You can also close it or iconify it.

If you look down at the right side of the control panel, notice the second icon from the center. Notice if you slide the pointer over an icon it will put up a bit of text to give an idea of the functionality. That second icon, if clicked, will bring up a new window which contains several icons, each giving a mechanism for configuring your workspace -- anywhere from changing the background color or pattern, to changing the fonts used for windows. You can explore these as you wish, but perhaps not now -- there's more of this tutorial to do.

Logging of the System

With your workspace in a condition you like -- the clock and terminal windows open, maybe you changed the background, the console window iconified -- now notice the ``EXIT'' sign located on the central part of the control panel. Click on this with the left mouse button. A window will appear asking if you wish to logoff -- respond in the affirmative. This is the process you will follow each time you leave the lab. After you logoff the system the login screen will appear -- login again. When your workspace appears notice it looks just as it did when you logged off.

Now for some things you are probably not familiar with.

A Few Useful UNIX Commands

The UNIX operating system is a very complex and powerful operating system and the backbone of Bucknell's extensive network of computers. In this lab we just introduce you to a few basic UNIX commands. Then, each week, we will introduce a few more commands and/or new options for previously discussed commands.

Once again we refer you to The Guide. This time read section 4.1 and do the examples shown. In the first paragraph of section 4.1, note the words in parentheses:

(possibly a shell window)
This refers to the Terminal window that you opened in the previous section. If you don't remember which one this was, look at the title bar for the word ``Terminal''.

Once you have worked through the examples of section 4.1, the date, and you think you have a handle on what you did, try the look command as follows -- be sure to leave a space between `look' and `frus':

look frus
Later you will be asked to give a written explanation of what you think look is used for. In your explanation, try to point out the connection between what the word ``look'' means and what the command does. Please Note: this is not a trick question and can be answered in a few short sentences.

The next commands are likely to be among the commands you use the most this semester. It is very important that you pay attention to spacing in these commands -- many of your early problems will stem from putting spaces where they don't belong or leaving spaces out where they do belong.

Copying Files

The first is the cp (copy) command, which is discussed in section 4.3.5 of The Guide. Later in this lab, you will be asked to load an IBM (Itty Bitty Machine) program into the IBM and run it. The filename of this program is lab1.ibm. (The ibm extension doesn't really mean anything except that it serves to remind humans that the file is an IBM program. We could just have well called the file: lab1.eatworms.)

The file lab1.ibm is currently located in the directory named ~cs203/Labs/Lab1. (We know we haven't told you what a directory is yet (a ``folder'' in Windows or Mac terms). We're saving that for next week.) You can copy the file to your own account by executing the following UNIX command:

cp ~cs203/Labs/Lab1/lab1.ibm .
Beware! There is a space after the command cp. There is no space between the tilde character ~ and cs203. The only other space on the line is between the ibm and the final period `.'. That final period is an important part of this command line!

The cp command instructs the system to copy the file lab1.ibm from the ~cs203/Labs/Lab1 directory into your account and name the copy of the file lab1.ibm. Issue this command now; be sure you include the final period with a space before it.

The last part of this lab requires another file you do not yet have. Issue the following command to put a copy of tutorial-1 in your account:

cp ~cs203/Labs/Lab1/tutorial-1 .

Checking on Files

To verify that these files were correctly copied into your directory, we will use the ls (list) command. This command is discussed in section 4.3.6 of The Guide; try out the examples in this section and make sure you have a fair idea of what the command does. You should see the files lab1.ibm and tutorial-1 in your list of files. If either file is not there, look at what you typed and compare it to the appropriate command above. If everything matches and you don't have the file, ask for help. If you typed in the command incorrectly, try it again. Make sure you have these files in your account before you continue.

At this point, we need to make some minor changes to the default settings in your ``log in'' files. The Engineering Computing Support Team has made this easy for us. Simply enter the following command:

new_dotfiles
If it asks to ``overwrite?'', type ``y'' and press Return. Now that your login defaults have been changed, you must log off and log in again in order for the changes to take effect. Do this now.

Printing Files

The final command we discuss is one that allows you to print files. To output the file lab1.ibm to the printer in your lab you would issue the following command (Don't issue this now!):

lpr lab1.ibm
It is convenient that the system is setup so that when you use a command with this form the output will always go to the printer in the lab where your current machine is located.

But if, for some reason, you want to print to a printer in a different room, you must slightly change the form of the print command to include an indication of the printer to use. If you take a look at section 4.6.1 of The Guide you will find a list of the names of printers in various rooms and labs. For example, to output a file to the printer in Dana 231 (from any room) you would issue the following command (don't do it now):

lpr -Plwc lab1.ibm
or equivalently
lpr -Pdana231 lab1.ibm
It is convenient that there is a naming scheme which identifies printers by building and room number.

Now, print a copy of lab1.ibm to the printer in your lab by using the first command above:

lpr lab1.ibm

Knowing how to output files to any one of the several printers listed in The Guide is an essential skill. Throughout the semester, there will be times when one or more of these printers is not working; to make matters worse, the room where the only working printer is located may be hosting a class at the time you need to print. Since students have access to so many printers, the line, ``The printer wasn't working.'', is not usually an acceptable excuse for not handing programs in on time.

Make absolutely sure you understand before continuing.

The Internet

You should be familiar with a web browser -- Netscape or Internet Explorer, most likely. On the Sun system only Netscape is supported. If you look down at the bottom of the screen, notice that the clock icon has a globe. If you click the left mouse button on the globe Netscape will be launched. Do that.

Most course materials for CSCI 203 will be available from the course web page whose address is

www.eg.bucknell.edu/~cs203
Enter that address into the browser and visit the page. On the CSCI 203 web page, you should see a link for today's lab in screen readable format. Click on this link. We will be making future labs available through the CSCI 203 web page in this format.

At this point you can iconify the browser. If you logoff the system with the icon there, the browser should be there ready for use the next time you login

The Mailer

Most students make use of either the Eudora or Outlook Express email programs or a browser-based email system, for example Hotmail or the new Bucknell webmail system. Since Eudora and Outlook Express are not available on the Sun system, if you want to do email while in the lab or otherwise logged into the Sun system you will have to use one of the browser-based alternatives -- the Bucknell webmail system is probably the most convenient. We will assume that you know how to use one of these systems.

At this point if you are unsure how to use email on the Suns please as the instructor or TA for help.

The Itty Bitty Machine

We've talked about the IBM in class. Now you get to see it personally. At the command prompt, type the following:

ibm &
You are looking at the IBM. Notice that all 100 memory locations contain ``000.'' The window starts out with two drop-down menus at the top, labelled File and Help.

To get things started click on File and then select the Load menu option. A moment later a smaller file browsing window will appear. Look for the list which is labeled Files and select the file named lab1.ibm; then click on the OK button at the bottom of this window. (If this doesn't seem to be working out as described, don't panic; just ask the TA or Instructor.) After clicking on OK you should see the interface change, with numbers being written into the memory and CPU portions. Also, notice the following: a new menu appears at the top of the window labeled Options, a red ``Step'' appears near the left end of the Itty Bitty Machine's screen, and stuff is written at the bottom of the window indicating the name of the file loaded and the starting address where the program is loaded. Also notice that if you run the mouse pointer over the red word ``Step,'' the characters turn green and back to red if pointer moves away from the word; similarly if you run the pointer into the region labelled Keyboard, a green border lights up around the region. When this border lights up it means you can enter keyboard data (up to 4 characters) by typing them on the physical keyboard.

Pay very close attention as you do the following exercise. You will be asked to explain what happened a little later.

The green Step acts as a button and allows you to execute the program one instruction at a time. That is, each time you click Step the IBM completes one fetch/execute cycle. Begin doing this now and watch what happens for each new fetch/execute; you should have some intuitive sense of what will happen based on what we have covered in class. After a couple (a few?) clicks you should see the keyboard region light up. When this happens you can type up to 4 characters -- do this slowly one keystroke at a time and notice what happens in the rectangle to the right of the keyboard region: hit the backspace key. Having entered a couple of characters into the keyboard buffer (the rectangle), return to stepping through the fetch/execute cycle. When you see Step replaced by the word Halted you have stepped through the entire program. You can restart the program by going to the File menu and selecting the Reload option. When you are sure of what the program does and feel you can explain it, select the Quit option on the File menu.

The emacs Editor

Remember the tutorial-1 file you copied into your account earlier? Now you get to find out for what it is a tutorial. At the system prompt type the following:

emacs tutorial-1 &
You just instructed the system to open the emacs text editor program and automatically load in the file called tutorial-1. You will need to move and resize the window a little. Move the window to the top of the screen. Grab the bottom of the window and stretch it until,
»Adjust the Emacs editor window to include this line.«
is the last line of text in the window. If you are not sure that you did this correctly, signal your professor or TA.

This file is a tutorial for helping you to learn how to use some of the features of the emacs editor. It is designed to be self contained so that no further instruction from us is necessary. Start reading through the tutorial and complete the exercises presented as you go along. If you have any problems, please ask questions.

Hand In

  1. Send your class professor an e-mail message containing the following:

    Your description of what the look command does. Remember, only a few sentences are required.

    A brief explanation of what the IBM program did that you loaded and stepped through. Again, we are not expecting an essay.

  2. Print a copy of the file which results from the emacs editor tutorial. If you did not rename the file when you saved it then the following command will work:
    a2ps tutorial-1

    The `a2ps' command places two pages on one sheet of paper, therefore, it saves paper.

  3. Remember to log off of the system before leaving the lab. Leave the machine on for the next user.



send comments to cs203@Bucknell.edu
2002-09-01