Unix Lab I

CS 29

Feb. 11, 1997

  1. Login to the Novell network. If you haven't used Windows 95 before, you'll discover that many things are ``hidden'' behind the Start button.

  2. Open a telnet session. We may have to experiment with this a bit. The host we're connecting to is unix1.psych.westminster.edu. If possible, use the vt100 terminal emulation.

  3. When you get the login prompt, enter your username. If you make a mistake, type ^u (hold down the ``ctrl'' key and press the ``u'' key) and start over.

  4. You'll need a password. I'll tell you what that is when we're all in the lab.

  5. When you've successfully logged in a lot of unimportant messages scroll by quickly. You may see the line:
    TERM = (hp)
    
    Type vt100 and press enter. You should now see the shell prompt:
    [1] %
    
    This prompt is how the system tells you it's waiting for a command from you. How nice to be waited upon like this.

  6. The first thing you should do is change your password. Run the passwd command to do this. Follow the guidelines I gave you for selecting a good password.

  7. Let's create a directory (folder). To do this, we use the mkdir command followed by the name of the directory which we wish to create. Type a space to separate the two. Pick any name you like for your directory.

  8. Now, enter your directory using the cd command. Again, follow the command name with the directory name you chose.

  9. To see where we are in the file system tree, use the pwd command. Go ahead and run it. Can you make sense of its output?

  10. Let's create a perl program file. We'll use the pico command to start an editor. Follow the command name with the name of the file which you want to create. Use an extension (suffix) of .pl in your file name.

  11. Pico is a little like using an editor in DOS. You can use the arrow keys to move around the text. The first thing you should do is read the help information. Looking at the menu at the bottom of the screen, can you figure out how to get help? (Hint: remember that ^ means press and hold the ``ctrl'' key.) Answer the following questions:
    1. How do you move forward a page?

    2. How do you move backward a page?

    3. How do you output the current buffer (file) to a disk file, in order to save it?

    4. How do you exit from pico?

    5. How do you move to the beginning of a line? To the end?

    As you become familiar with pico, you'll find more and more of these commands useful.

  12. Exit from help.

  13. Let's write our first perl program. Here's a short program to add two numbers and print the sum. Type it in, save it, and exit from pico:

    #!/usr/contrib/bin/perl
    
    print "Please enter the first number: ";
    $first = <STDIN>;
    
    print "Please enter the second number: ";
    $second = <STDIN>;
    
    $sum = $first + $second;
    
    print "The sum is $sum.\n";
    
    exit 0;
    

  14. You must now make your file executable. Use the command chmod u+x followed by your file name. Now run the command ls -l. (The period is a part of the sentence, not the command.) The beginning of the line for your file should start off with -rwx. If it doesn't, stop and call me over.

  15. Run your program. Let's say you named your program file add.pl. To run your program type ./add.pl (substitute the file name you chose). Did your program do what you expected?

  16. Run pico on your file again. Modify your program so that you add together 4 numbers. ( Note: CS majors should modify the program so that it keeps adding together numbers until a 0 is entered, then prints the sum and exits.) You won't have to run the chmod command again; it only needs to be run on a file once.

  17. When you've finished, use the logout command to log out of the system, then log out of Windows 95.



Thomas P. Kelliher
Mon Feb 10 20:16:23 EST 1997
Tom Kelliher