CIS126AA,BA,CA Syllabus

(Typical Class, NOT OEOE!)

UNIX Operating System

 

INSTRUCTOR:  C. RAY ESPARZA, BUS‑ 01‑124, 623-845‑3237

EMAIL – ray.esparza@gcmail.maricopa.edu or cesparza@gnix.gc.maricopa.edu

 

TEXT:  UNIX Unbounded A Beginning Approach, 3rd or 4th Edition,  by Amir Afzal

 

Objective:  To teach students the basics of the UNIX operating system including basic commands and UNIX structures.  Included will be an overview of all major commands and many useful commands.  The course will finish with some minor scripting examples done as lab assignments for individual credit.

 

Procedures

 

 

You are expected to read the current chapter in the text before you come to class.  Class discussions will be based largely on student questions concerning the current topics.

 

There are several required lab assignments. All lab assignments are described in detail in handouts to be distributed at a later date.

 

Taking Tests

 

There will be 3 quizzes (50 points each) each Quiz will represent the end of each of the three sections of CIS126AA, BA, and CA.

 

All Quizzes MUST be taken during the last week of each class unless an “Incomplete” is previously arranged!

 

Grading

 

Make-up tests will receive face value grades with no adjustments or credits and will be docked an additional 10% for unexcused absences.

 

Grades will be determined from the following for CIS126AA and BA only:

Quizzes                                        1  @  50      =          50 points

Terminal Sessions Homework     4  @  10        =          40 points

Attendance                                                                   10 points

                                                               Total=     100 points

 


CIS126CA ONLY

Quiz                                         1  @  50          =          50 points

Lab assignments:                       1  @    5          =            5 points

                                                3  @  15          =          45 points

                                                Total                =       100 points (CIS126CA Only)

 

Tentative Class Schedule:

Date

=========== CIS126AA=======================

=======================

1/15/03

Introductions and Class overview

 

1/17

Introduction

Chapter 1

1/22

The UNIX Operating System

Chapter 2 Practice Session

1/24

Getting Started

Chapter 3

1/29

 

Terminal Session

1/31

The vi Editor

Chapter 4

2/5

 

Terminal Session

2/7

Introduction to UNIX File System

Chapter 5

2/12

 

Terminal Session

2/14

Quiz 1

END of  CIS126AA

=========

=========== CIS126BA =================

=======================

2/19

The vi editor: Last Look

Chapter 6

2/21

 

Terminal Session

2/26

The UNIX File System Continued

Chapter 7

2/28

 

Terminal Session

3/5

Exploring the Shell

Chapter 8

3/7

 

Terminal Session

3/11-15

SPRING BREAK

 

3/19

UNIX Communication

Chapter 9

3/21

 

Terminal Session

3/26

 

 

3/28

Quiz 2

END of  CIS126BA

=========

=========CIS126CA ====================

=======================

4/2

Program Development

Chapter 10

4/4

 

Terminal Session

4/9

Shell Programming

Chapter 11

4/11

 

Terminal Session

4/16

Shell Scripts: Writing Applications

Chapter 12

4/18

 

Terminal Session

4/23

Farewell to The Shell

Chapter 13

4/25

 

Terminal Session

4/30

 

 

5/2

Quiz 3

All Previous


CIS126CA ONLY     Lab Assignments due one week following chapter covered:

 

Lab Ch 10

In this assignment you are to write a sample C program. It is not expected that you know C programming. Copy the simple C program example in this chapter or one from any C programming book. The purpose is to familiarize yourself with the process of program development.

 

 Enter this simple C program using any editor (vi or ed or cat >). 

 

/*  a simple program entered by sapilcha  */                  ç put YOUR userid here

# include <stdio.h>

main()

{

printf  (“Hello there, my name is Semolina! \n”);             ç put YOUR name here

printf (“This is my second but very simple C program. \n”);

}

 

Save it as prog2.c

 

 1.  Start a script file with the name  youruserid.chap10.

 

 2. Compile the prog2.c program.

 

 3. Run the new program.

 

 4. Compile it again and specify the executable file as prog2.

 

 5. Run it again.

 

 6. Save the output of your program in another file called prog2.output .

 

 7. Modify your source code and make an intentional syntax error by deleting one of the semi-colons.

 

 8. Compile again.

 

 9. Observe the error messages. See if you can decipher them.

 

10. Use ctrl-d to close the script file. 

 

11.  Print out:

a.        the script file

b.       the prog2.c file

                c.   the prog2.output file


Lab Ch 11

 

Write a shell script named showparms which will disp1ay each positional parameter from the shell command line (including $0), as well as the argument count $# and the entire set of command line parameters $@.  Your script should display as many positional parameters as there are arguments, but if there are more than nine arguments on the command line display only the first nine positional parameters ($1 through $9).  In either case, $@ should show all of the arguments.  Be sure to include appropriate comments in your script so I will know what your script is doing.  Each parameter should be displayed on a separate line which shows the parameter name and has the parameter value delimited by the angle brackets < and > so that it will be possible to see an argument which consists of a null string (“”) or a blank space or spaces (“  “).  As an example:

 

$ showparms 3 “ ” “a b c” “” “Dec 15”

 

Your ouput should be like this:

 

$# = 5

$0 = <showparms>

$1 = <3>

$2 = <  >

$3 = <a b c>

$4 = <>

$5 = <Dec 15>

$@ = <3  a b c Dec 15>

 

The $@ is a list of all arguments.  When displaying the value for $@, make sure you can account for all of the space characters which are displayed.  There should not be too few or too many.  In the example above, there is one space between each of the command line arguments, one additional space for the parameter $2 since it is “  ” and no additional spaces for the parameter $4 since it is “”.

 

Execute your script with a command line of fewer than nine arguments and a command line of more than nine arguments.  When there are fewer than nine arguments you should only display as many positional parameters as there are arguments.  For example, if there are four arguments you should not display the $5 argument.  IF there are more than nine arguments then you should not try to display $10 since there is no such thing!


Lab Ch 12

 

This 15 point lab is a while or until loop script which does the following:

 

  1. Display a two-line prompt which says:

 

Type one or more words, then press <Enter>

To end, just press <Enter>

_

 

after displaying the message the cursor should be at the start of a new line as shown above by the underscore character.

 

  1. Read keyboard input when the <Enter> key is pressed. 
  2. If only the <Enter> key was pressed then display the message:

 

Exiting program

 

And then end execution by using the logic of your script.  Do not use exit or break statements.

 

  1. If there is some input, then count the number of words and characters in the input string and display:

 

You typed ww words and cc characters

 

Where ww is the word count and cc is the character count.

 

  1. Loop back to step A and continue the script until nothing is input.

 

Notes:

 

Don’t forget to use appropriate first line and comments in your script.  You will need a read statement to read the keyboard input and assign it to a shell variable.  The loop condition should be that it will terminate upon reading a null string from the keyboard.  To count words and characters echo your shell variable which contains the input, and pipe it to a wc command with appropriate switches to count words then characters.  Use command substitution (back quotes) to replace the echo, pipe and wc with the number which results from executing these commands.  Your command substitution, echo, pipe and wc commands will all be within one larger echo command to display the whole output message from instruction “A”.  Be sure to quote your shell variable when you are testing it because a shell variable which contains a null string will seem to disappear when you try to test it unless it is inside quotes.  You may need to initialize your shell variable with a “seed” (non-null) value in order to get inside the loop to begin execution of the loop the first time.


Lab Ch 13

 

This 15 point lab is a case script which does the following:

 

Write a script named “greeting” which will display a greeting on the screen, based on the current time of day and day of week.  This is very similar to the lab from the Introduction section of this course guide but will be constructed entirely different using case statements and the date command.  Some sample greetings are as follows:

 

If it is 8:00 pm on Wednesday :

 

            Good evening, today is Wednesday.

 

If it is 9:12 am on Sunday:

 

            Good morning, today is Sunday.

 

Or if it is 3:45 pm on Friday :

 

            Good afternoon, today is Friday.

 

The greeting should say “Good morning” between the hours of  midnight (00) and 11:59 am, “Good afternoon” between noon (12) and 5:59 pm, and “Good evening” between 6 pm and midnight.  Don’t forget the date command uses Military time.

 

The greeting should supply the complete name of the day of the week, not just the three letter output of the date command.  

 

A suggested, but not mandatory, approach is for your script to execute set on the date command in backquotes (I told you way back you would need this).  Recall that this places the output of the date command into the format :

Sat  Dec  16  14:45:34 MST 2000           ç output of `date` command

$1    $2    $3   $4          $5       $6             ç positional values set

 

You may now use the positional variables ($0-$9) in a for loop.This will supply the abbreviations of the day of the week as $1 and the time of day as $4.  Use a case statement to assign the full name of the week to variable in your script.  Use another case statement to assign the time of day (morning, afternoon, or evening) to another variable in your script based on the pattern of the time of day in $4

Finally, echo the required output line using the two variables you used in the case statements.