STTS         Getting Logged on to UNIX       Name ____________________
     
     
     1. Login - notice all the messages you get when you log in.  What is
        today's Message Of The Day?
     
     
     
     
     
     2. Change your password using the 'passwd' command, if you haven't
        changed it recently.
     
     3. Practice typing something in and using the ctrl-h key to backspace. 
        Type 'datf'.  Now change it to 'date' by backspacing and erasing the 
        'f' and replacing it with an 'e'.
     
     Experiment with the following commands:
     
     	TYPE IN			WRITE DOWN THE RESULTS OF THIS COMMAND
     	_____________		_________________________________________
     
     4. date
     
     
     5. cal 
     
     
     6. cal 1 2000
     
     
     7. who     (How many people are logged on?  Who logged on first?)
     
     
     8. finger ? (where ? is your last name)
     
     
     9. finger ? (where ? is your userid)
     
     
    10. What day of the week were you born? ___________________
     	cal m yr            (where m is the month you were born and
                             yr is the year you were born)
    11. Logout





     STTS               Email-pine                Name ____________________
     
     1. Mail a message to yourself using the  pine  mailer.
        List below the command that allows you to do that:
     
     
     
     2. Mail a message to your neighbor.  List below the command that allows 
        you to do that:
     
     
     
     3. Read your mail.  Did you find a message from yourself?  Did the message
        from your neighbor turn up?
     
     


        Repeat steps 1 to 3 until you feel comfortable with sending and
        receiving mail.
     

     4. Try using 'talk' to converse with your neighbor.  Do you like this mode
        of communication?  Describe why or why not.
     
     
     
     
     	
     
     5. Use 'man' to find out about the commands 'date', 'cal', and 'ls'.
        How many options does ls have?




     STTS	Files and Directories             Name ___________________
     
     1. Login to the mode machine and continue when you are ready.
        Start up  script  by entering    script Wednesday
     
     2. From your home directory, issue an 'ls -al' command.
        Describe what appears.  Compare that to an 'ls' command.
     

     
     
     
     3. How many non-directory files are in your home directory?___________
     
     
     4. How many subdirectories are in your home directory?_________________
     
     
     5. Now from your home directory, change directories to the Challenge
        directory of /usr/local/scc  (use 'cd' to change to this directory).
        Answer the following questions about this directory.
     
     6. How many non-directory files are in this directory? ____________
     
     7. How many subdirectories are here? ______________
     
     8. Which file is the largest?___________
     
     9. Which non-directory file was most recently modified? _____________
     
    10. What is the present working directory? _________________
     
    11. Which command gave you the answer to the question above? _______________

    12. How would you view the contents of the file called sponsors.addresses?


    13. When was the '/etc/passwd' file last modified? _______________
     
    14. Which command did you use to give you the information you needed for
        this question? ______________
     
     
    15. Now return to your home directory. Which command allows you to do this?
    
    16. Create a file using the following redirection commands:
     	
     	% who > testfile
     	% cal 2000 >> testfile
     
    17. Now that you have this file created, get a copy of it on the laser
        printer with the command below: 
     
     	% lpr -Ppp testfile
     
     Submit this printer copy with the rest of this assignment.
     
     
    18. Get out of script with a ctrl-d (^d) and send the script file to the
        line printer with   lpr Wednesday
     

    19. What is the difference between using CAT and MORE to look at the 
        Wednesday file on the screen?  Which do you like better and why?
     
     
     
     
    20. Using redirection, mail a copy of testfile to yourself. What command
        allows you do do this? 
     
     
     
    21. Now delete this file called testfile. What command allows you to do
        this? 
     





     STTS   File and directory commands, Metacharacters    Name__________________
     
     
     Start a script file to demonstrate what you did for exercises 1 to 10 below.
     Submit this script file as part of this exercise.
     NOTE: all commands are shown below in upper case for clarity only.
     
     
     1. In your home directory, issue a PWD and an LS command to show where you
        are and what files and directories are there.
     
     
     2. Use the CP command to copy one of your files into another file
        called 'one'.  Do an LS to show the copy was made.
     
     
     3. Use the MV command to rename this file from 'one' to 'two'. Do
        an LS command to show the rename was done.
     
     
     4. Use the MKDIR command to create a directory called 'project'. Do an
        LS command to show the MKDIR was done.
     
     
     5. Now place a copy of the file called 'two' into the 'project' directory 
        and call the new file 'three'. Do a CD command into 'project'.
        Do an LS command to see if the file 'three' is there. 
     
     
     6. Return to your home directory. What command allows you to do this?_______
     
     
     7. Use the MV command to move the file 'two' into the 'project' directory.
        Use the LS command to show that the file 'two' is now missing from this
        directory.  List the 'project' directory to show that the file 'two' is 
        now here.
     
     
     8. Now make a copy of a file which is in the /usr/local/scc/examples
        directory.  Choose either a Fortran or C (C++) source file.
     
     
     9. Use the CP command from your home directory to make a copy of an
        examples file, but call it a different name in your home directory.
     
     
     10. Do a final LS to demonstrate that the two files copied in #8 and #9
     are here in your home directory. 
     
     NOW END THE SCRIPT FILE.
     
       Submit the script.
     
     For the exercises below, go into the /usr/local/scc  directory. 
     From here, you will be able to practice using the LS, CD, CP, and MV 
     commands with pattern matching for file names.  NOTE: In some cases, 
     you will NOT have permissions to make the changes suggested, so you
     will just have to tell me what WOULD happen if you did have permissions
     to issue the given commands.
     
     11. What is the command you will issue from your home directory to get you
         into this directory?
     
     
     12. What is the command which would list all files with the prefix 'assign'?
     
     
     
     13. What is the command which would list all the files with 'amp' in the
         name?
     
     
     
     14. What is the command which would allow you to list all the files and
         subdirectories in the 'Fortran' directory without actually leaving 
         the '/usr/local/scc' directory?
     
     
     
     15. Without leaving the '/usr/local/scc' directory, copy the radium.f
         file in the Fortran directory to your project subdirectory.







     STTS         Using C/T Shell Features        Name ____________________
     
     
     1. Login to mode.

     2. Enter  history  to see what you have done recently.
     
     3. Re-execute a command from your history buffer.

     4. Enter  ls /usr/local/ssc/examples
        then correct the  ssc  to  scc  with the ^ function

     5. Enter  ls /usr/local/ssc/examples
        then correct the  ssc  by using the up arrow and back arrow.
     
     6. Using the command line substitution method (:s), correct the
        very first  ls /usr/local/ssc/examples  command and rerun it.
     
     7. Copy the C++ program random.c from /usr/local/scc/examples,
        compile it, and run it.  Run it redirecting its output to
        a file called random.out and then look at that file.
     
     8. Run random two more times, appending its output to random.out
        each time.
     
     9. How many lines are in random.out by now?
     
     
    10. Play with filename completion.
        cd to your public_html directory by entering  cd pu
        list your index.html file by entering  ls i







     STTS      Customizing the Unix Environment   Name ____________________
     
     
     1. Login to mode.

     2. Create an alias to cd to your public_html directory and put
        it into your .cshrc file then source the .cshrc file.  It
        should work when used from any directory.  Show it here:



     3. Create an alias called  ls  that really does an  ls -alF



     4. Disable the ls alias.  Show how you did that:



     5. If you regularly read email on the a machine other than mode,
        create a .forward file that keeps a copy of the message and 
        forwards a copy on to your other address.  Then TEST it!
        The contents of the .forward file should look like:
           \chtabcde
           abcde@some.nmhs.edu

     6. Look at the Environment variables that are established (printenv).

     7. Look at the Shell variables that are established (set).

     8. Display all the aliases that are active.  How many do you have?



     9. How many customizing dot files are in your home directory?


    10. How many history commands are saved when you log out?






     STTS      Foreground/Background Processing   Name ____________________
     
     
     1. Login to mode.

     2. Enter  ps  and see what processes you have running.
        What are they?


     3. Enter  ps -ax  and see what processes are running on mode.
        How many are there?



     4. Enter  vi junk  and then stop it with ^Z


     5. Enter  ps  and kill the stopped vi process.  What command
        did you use?




     6. Enter  vi junk  and then stop it with ^Z then enter  jobs


     7. Bring vi back to the foreground and exit it with  :q


     8. Compile random.c in the background.  Show how you did that:



     9. Use  top  to see what is running on mode.  Use  q  to quit top.


    10. Use more to view a large file, but kill it with ^C





     STTS	The VI Editor                     Name_____________________
     
     1. Login to your home directory. 
     
     2. Copy the file 'goldyou.C' that's in the /usr/local/scc/stts/editors
        subdirectory into your home directory. You can do this by typing:
     
     		 cp /usr/local/scc/stts/editors/goldyou.C goldyou.C
     
     This will copy (cp) the file called goldyou.C from that directory
     into your home directory.  To make sure that the copy worked, now
     do an 'ls' to find a list of all the files in your home directory
     and see if 'goldyou.C' is there.
     
     3. Once you have your own copy of goldyou.C, you may make the 
     modifications below.  Please submit a copy of this modified file
     as a homework exercise.  Your final, modified file should look
     something like the file on the back side of the page.
     
     	a. First practice moving around the file with the following commands: 
     	    move by a single character: j, k, l, h.
            move by a word: w, b
     	    move up and down by a whole or half page: ^d, ^b, ^u, ^f
     	    move to the nth line: nG
     	    move to the line with an expression: /expression
     	    
     	b. INSERT: 
                Move to the first line of the file.
     	   Use the 'O' command to insert a new first line 
                containing your name, userid, and the date.
     	   This line should begin with  // 
     	   Don't forget to hit 'esc' to end insertion mode.
     
     	c. INSERT BELOW with o: 
     	   Move to the line with the expression:    407.00
     	   (Remember to use the /407 search feature.)
     	   Now use the 'o' command to go into insertion mode and
     	   add the following NEW LINE below the cursor:
     		// Calculate the user's value
     	   Don't forget to hit 'esc' to end the insertion.
     
     	d. INSERT AT END OF LINE:
                 Move to the line which contains the expression:
     		If gold prices drop 
     	   Position the cursor to the end of the line and
                use the 'a' command to add a semicolon (;)
     	   Don't forget to hit 'esc' to end the insertion.
     
     	e. DELETE A WHOLE LINE:
     	   Move to the line that contains the following line:
     	         cout;
     	   Delete this line using the 'dd' command.
     
     	f. DELETE A WORD:
     	   Move to the line that contains the expression:
     		 easily easily
     	   Delete the first word 'easily' using the 'dw' command.
     
     	g. REPLACE WORD:
     	   Move to the line that contains the expression:
     		maintain your value
     	   Replace the word 'value' with 'worth'.
     
     	h. YANK AND PUT:
     	   Move to the line that contains the expression:
     		// this is a line to yank
     	   Use the 'yy' command to yank this line and put a copy of it into
     	   a buffer. Notice that the original line remains unchanged.
     	   Now go to the last line of the file and use the 'p' command. Notice
     	   that a copy of the line you 'yanked' is inserted into the file. 
     
     	i. YANK AND PUT:
     	   Move to the first line of the file.
     	   Yank this line which contains your name, etc.
     	   Put a copy of this line after line #20.
     
     	j. SAVE AND EXIT:
     	   Use the 'ZZ' or ':wq' command to write the contents of this 
     	   editor buffer to the permanent file and quit.
     
     // Joe Student, cs101kyy, Dec 31, 1999
     // goldyou.C -- the worth of your weight in gold
     // 
     // This is a C++ program that will compute the value
     // of some number of pounds of gold.
      
     // To compile this program enter    CC goldyou.C -o goldyou.x
     // and to run the program enter     goldyou.x
     // It will ask for you weight, in pounds
      
     #include 
     void main ()
     {
        float weight, value;      // floating-point variables for the user's
                                  // weight and the value of gold.
      
        cout << "Are you worth your weight in gold?\n";
        cout << "Please enter your weight in pounds, ";
        cout << "and we'll see. ";
        cin >> weight;             // get the user's weight
     // Joe Student, cs101kyy, Dec 31, 1999
      
     // this is a line to yank
        value = 407.00 * weight * 14.5833;
     // Calculate the user's value
                                  // assumes gold is $407 per ounce
                                  // 14.5833 converts pounds to troy ounces
      
        cout << "Your weight in gold is worth $" << value << endl;
        cout << "You are easily worth that! \a\n If gold prices drop, ";
        cout << "eat more to maintain your worth." << endl;
     }
     // this is a line to yank





     STTS	EX EDITOR from VI             Name__________________
     
     1. Login to your home directory. 
     
     2. Copy the file 'hilow.C' that's in the /usr/local/scc/stts/editors
     subdirectory into your home directory.  You can do this by typing:
     
     		cp /usr/local/scc/stts/editors/hilow.C hilow.C
     
     This will copy (cp) the file called hilow.C from that directory into
     your home directory.  To make sure that the copy worked, now do an 'ls'
     to find a list of all the files in your home directory and see if 'hilow.C'
     is there.
     
     3. Once you have your own copy of hilow.C, you may make the modifications
     below.  Please submit a copy of this modified file as a homework exercise.
     Your final, modified file should look something like the file on the back.
     Notice that while VI lets you move around the file visually, the ex command
     only allows you to specify a line # or a range of #'s (called addresses), 
     followed by a command.  Start up VI then use the colon (:) to give EX
     commands.
     
        a. ACCESSING DIFFERENT LINES
     	  n	display the n'th line of the file. Put in a number where n is.
     	  n,k   display lines n through k of the file
     	  .     display the current line
     	  $     display the last line of the file
          /pattern   display the line with this pattern. Similar to VI.
     
     	b. DELETE A WHOLE LINE:
     	   From anywhere in the file, delete the third line with:
                      :3d
     
     	c. REPLACE WORD:
     	   Move to the line that contains the expression:
     		David's high-low
     	   Replace the word 'David' with your name
     		:s/David/Joe/
     
     	d. SUBSTITUTE
     	   The editor ex is famous for its substitution capabilities. Take
     	   advantage of it by trying these commands below:
     	     :1,$s/a/x/g	   - for all lines 1 to $, substitute all
     				   occurrences of 'a' with 'x' on entire line.
     
     	     :1,$s/plxy/try/g
     
     	e. SAVE AND EXIT:
     	   Use the 'ZZ' or ':wq' command to write the contents of this editor
     	   buffer to the permanent file and quit.
     
     //FILE: hilow.C
     //Plxys the high-low guessing gxme
     #include 
     #include 
     #include  //NEEDED: to include system time-relxted functions
     #include  //NEEDED: to include system time functions
     const int upper_limit = 1000; //NEEDED: to initixlize vxlid upper limit
     const int lower_limit = 1; //NEEDED: to initixlize vxlid lower limit
     void mxin()
     { time_t tloc; //used to get informxtion from computer xbout system functions
       int high;    //current highest guess
       int low;     //current lowest guess
       int secret;  //computer generxted rxndom number, between lower xnd upper
       int guess;   //input from the user
       int counter; //mxke sure they only get 20 guesses
       int done;    //to know how the loops ended
       chxr xgxin;  //try xgxin?
       srxnd(int(time(&tloc))); //NEEDED: to seed the rxndom # generxtor
       do
       { cout << endl << "Welcome to Joe's high-low guessing gxme" << endl;
         cout << "Be smxrt xnd you will win" << endl << endl;
         high = upper_limit;
         low  = lower_limit;
         counter = 0;
         secret = lower_limit + (rxnd() % (upper_limit - lower_limit));
     //Ask the user to guess
         do
         { done = 0;
           counter++;
           cout << "Plexse enter guess number " <> guess;
      //Check guess
           if (guess < low)
                 { cout << "Out of rxnge, too low, you loose" << endl;
                   done = 1; }
           else if (guess > high)
                 { cout << "Out of rxnge, too high, you loose" << endl;
                   done = 2; }
           else if (guess < secret)
                 { cout << "Too low, try xgxin" << endl;
                   low = guess; }
           else if (guess > secret)
                 { cout << "Too high, try xgxin" << endl;
                   high = guess; }
           else // guess == secret!!
                 { cout << "You guessed it!!" << endl;
                   done = 3; }
         if ((counter >= 20) && (done != 3))
           { cout << "Too mxny guesses, the secret number wxs " << secret << endl;
             done = 4; }
         } while (done == 0);
       cout << "Do you wxnt to try xgxin? [y/n] ";
       cin >> xgxin;
       } while (xgxin == 'y' || xgxin == 'Y');
       cout << "Thxnks for trying!" << endl;
     }





     STTS         Using Programming Languages         Name__________________
     
     
     For this exercise, you will copy several programs into your home directory
     from the /usr/local/scc/stts directory and compile and run them.
     
     1. Using the CP command, copy the two files 'example.c', and 'example.f'
        from the /usr/local/scc/stts/programs directory into your home directory
        under the same names.  You will notice that the program ending in the .c 
        extension is a C program, and the file 'example.f' contains a 
        Fortran program.
     
     
     2. Using the CP command, get clean copies of 'goldyou.C' and 'hilow.C'
        from the /usr/local/scc/stts/editors directory if you need to.  They
        are C++ programs.
     
     
     3. Now compile the Fortran 'example.f' with the command below, and 
        notice that it produces an 'a.out' file in your directory.
     
     	f77 example.f
     
        In order to run this program, just type 'a.out'.  This program
        will flip a coin for you, you get to decide how many times it
        does it.  See what the output is. Show what the program produces 
        below:
     
     
     
        You may run this program as may times as you want simply by typing
        'a.out' to the Cshell prompt. 
     
     
     4. Now edit 'example.f' and remove the 'c' in column one of the line:
     
     c        write(11,103) flip, ran
     
        so that each flip and random number is printed to a file.
     
        What is the name of that output file that holds the random numbers?

     
     
     5. Remove that output file.  What command did you use? ____________
     
     
     6. Now use the command 'cc example.c' to compile the C program 'example.c'. 
     
        What file is produced when you perform this compilation? _______________
     
        How do you tell the computer to run this program? ______________________
     
        Explain in 1 or 2 sentences what this program does:
     

     
     7. Now use the command 'CC goldyou.C' to compile the C++ file 'goldyou.C'.
     
        What are you worth in gold? __________________
     
     
     8. Now compile 'hilow.C' and play it a few times.
     
        What is the best you can do at guessing the secret number? _____
  
     
     9. Edit 'hilow.C' and remove the  {  under the word 'void' and
        re-compile the program to see how much that confuses the compiler.
     
        How many errors did the compiler detect? ___________________
  
     
    10. If you still have your original version of hilow.C (the one where
        we replaced all occurrences of the letter  a  to  x), compile that
        and see how the compiler likes it!