Home Slides Assignments

COMP 2400: Assignments

Lab 8
Due Date: November 10th, 2008 (Nov. 11th for the TR class)

In this lab, you will use Rexx again to write a program that performs a simple guessing game. You start it by passing in an argument that tells it what range to guess from. You then query the user and tell them if their guess was too low or too high. Finally, once they guess correctly, you inform them and print out all the guesses they made up until that point.

For example:

$ ./lab8 10
$ Guess a number from 0 to 10:
$ 5
$ Too high, try again.
$ Guess a number from 0 to 10:
$ 3
$ You're right!
$ You guessed: 5, 3.

Quiz 3, Extra Credit
Due Date: November 10th, 2008 (Nov. 11th for the TR class)

You may attempt problem 2 from Quiz 3 for extra credit. Place your solution in a file called p2 under the directory quiz3extra at the top level of your repository (like everything else).

You can get to the quiz at: Quiz 2

Lab 7
Due Date: November 5th, 2008 (Nov 6th for the TR class)

In this lab, you will use Rexx to write a program that takes two arguments and prints out the multiplication of all pairs of arguments between them.

For example, if I wrote the script lab7, and called it as:

lab7 2 4

I would get:
2 * 2 = 4
2 * 3 = 6
3 * 3 = 9

You will need to use the command PARSE ARG to get the command line arguments. Call your script lab7 and put it in the lab7 directory.

Homework 3
Due Date: November 10th, 2008 (Nov. 11th for the TR class)

For this homework, you will use bash to write a script that, once started, monitors the process list of the operating system. Anytime a new process is started, it will be log the time, the user, and the process name to standard output. Alternately, you can pass a flag into your script, with '-f' to specify where to log the output to.

To do this, you will need to loop and watch the ps list. You may in fact miss short lived processes, which is fine, I only expect you to catch the ones from one iteration of the loop to the next. You should watch all processes by all users, not just your own processes.

Save this in your HW3 directory and call the script 'procmon'.

Lab 6
Due Date: October 29th

In this lab, you will write a script called pinfo, which combines information from 'jobs' and 'ps' to print a list of jobs with their job numbers, process IDs, running times, and full commands. You must use information from both commands. Submit it under a directory named 'lab6' with the filename 'pinfo'.

To test your script, you need to source it by typing '. pinfo' or 'source pinfo' as bash will run your script in a subshell, which can't get information about jobs of the parent shell.

Homework 2
Due Date: October 22nd, 2008

Now that you've had some bash practice, you will write a bash script to do the following:

  1. Take a single argument that is a directory.
  2. Traverse that directory recursively and delete all .svn sub-directories.

You must use loops to demonstrate your understanding of loops in bash.

Place this under directory HW2 in the top level of your repository. Call the script rmsvn

Lab 5
Due Date: TBD

For Lab 5, you will write a program that queues and dequeues items to a list. Recall that a queue has the FIFO (first-in, first-out) property while a stack has the LIFO (last-in, first-out) property. Your code must have four functions:

  1. enqueue: a function which takes an element to queue up, returns 0 if the queueing was successful, 1 otherwise.
  2. dequeue: a function dequeues an element, returns 0 if we can dequeue and 1 if not.
  3. top: a function which echos the top of the queue to standard output.
  4. clear_q: a function which clears the queue
You will need to have a global variable, QUEUE, which the functions use as a queue. This means you will need to export it. Please name the directory lab5 and the script lab5.sh. We will source your script and test it (which you should most definitely do).

Reading 5

Read chapter 35, for beginning shell programming. Clearly you'll probably want to skip the stuff on non-bash shells.

Lab 4
Due Date: Wednesday, October 8th (MW class), Thursday, October 9th (TR class)

In today's lab, you will write your first bash script. This script will use wget to get an RFC from the main RFC repository at http://www.ietf.org/rfc/rfcNNNN.txt. You will display the contents of it to the screen using a paging program (preferably the less command).

Your program must do checking to make sure the command executed properly or echo an error if it couldn't. If no arguments are listed, you must print out a usage message of the following format:

"Usage: rfc will display the contents of the rfc on screen."

Lab 3
Due Date: Monday, October 6, 2008 (MW class), Tuesday, October 7, 2008 (TR class)

For this lab, you will do the following problems by writing a regular expression. Place your answers in a text file, one answer per line beginning with n., where n is the number of the problem and put them under a lab3 directory in your repository. We are going to simplify the regular expressions by assuming that only the letters a and b are in the alphabet. In addition, we are going to make it more difficult by assuming that . is not usable (ie, you may not use .+ in your regular expression):

  1. Each a in any word is immediately followed by the letter b.
  2. Any word has abab as a substring.
  3. Neither aa or bb are found in a word.
  4. A word has an odd number of a's and an even number of b's.
  5. The word has both ab and ba as a substring.

Reading 4

Read chapter 32 for more details on regular expressions.

Homework 1
Due Date: Fri, September 26th, 2008

For this assignment, you are going to research vi alternatives and report on one of them. The restriction here is that they must allow you to edit from the console (ie, you don't have to be in X-Windows of some form). Your choices are:

I'm also open other editors if you have a favorite, but you must email me to get approval first!

Your report should have:

Now ideally you'd use the text editor you're researching to write all of this, but I can't check that, so it's not a requirement. However, it's probably character building to do so! Save this file to a text file inside a directory called 'HW1' and put it in the top level of your repository.

Reading 3

Read chapters 7 and 8 from Unix Power Tools. This covers things about your directory, moving around, creating directories and such.

Lab 2
Due Date: Wed, September 24th, 2008 (MW class), or Thu, September 25th (TR class)

For this lab, you must edit two files at the top level of your home directory: .cshrc and .profile. For .cshrc, you will need the following two lines:

# execute bash shell
exec `which bash` -l
For your .profile, you want the command added (if the file already exists):
export SHELL=`which bash`
You must then create a lab2 directory in your repository at the same level as lab1. Inside, I want two files, cshrc and profile, without the leading period. We'll check them out and grade them.

Reading 2

Read chapter 17, which covers 'vi'. For the industrious, read 18.

Lab 1
Due Date: Wed, September 17th, 2008 (MW class), or Thu, September 18th, 2008 (TR class)

This first lab is simple: use subversion to create a directory in your repostory called 'lab1' and inside it, place a file called 'lab1.txt' which contains the text: "I should get an A for this lab!" in it. Commit it when you're done.

Reading 1

Read chapters 1 and 2 for Unix background material from Unix Power Tools. As with all material from this book, part of your job is to filter out unnecessary information. How do you know what material that is? Well, for example, we're not studying the c-shell nor the z-shell, so you can safely ignore that information for now (but it may come in handy at some point in your career).

Lab 0 (only the MW class)
Due Date: Mon, September 15th, 2008

For this lab, you need to simply email me and tell me what the first numeric value after the permissions when you execute ls -l stands for. Why is it a 1 or higher value?