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.
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
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.
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'.
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.
Now that you've had some bash practice, you will write a bash script to do the following:
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
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:
Read chapter 35, for beginning shell programming. Clearly you'll probably want to skip the stuff on non-bash shells.
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."
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):
Read chapter 32 for more details on regular expressions.
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:
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.
Read chapters 7 and 8 from Unix Power Tools. This covers things about your directory, moving around, creating directories and such.
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` -lFor 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.
Read chapter 17, which covers 'vi'. For the industrious, read 18.
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.
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).
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?