UC Irvine, Information and Computer Science Department

ICS 54 Winter 2000: Homework 4

This assignment is to be done individually.
All work for it should be done in a special directory (on a UCI UNIX system, either ICS or OAC-EA) which you set aside for the purpose which contains no other work and which you keep for future reference and use in this course.
Suggestion: Have a ics54 directory and put the work for this assignment in an ics54/hw4 subdirectory.
This assignment is due at the start of class, Wednesday, February 23.
You will turn in a printout with a separate cover/title page containing:
(1) Your Personal Identification (Name, Student ID number, and UCInetID),
(2) Assignment Identification (course name and quarter plus assignment number).
Please print separate parts of the assignment on separate sheets and label the pages appropriately.

The TA will be available in CS 364 at the following times:

The Instructor will also be available in his office (Engineering Gateway 2149):
  1. In homework assignment 3, you created a shell script MyFriends, which listed all the processes your friends were running. For this problem, you will create an advanced version of MyFriends - MyFriendsV2. It accepts arguments, which are either your friends' login names (login IDs) or files which contain lists of login IDs (one per line). If an argument is a file name, you can assume it is a file containing a list of login IDs (one per line). If it is not a file name, you can assume it is a login name.

    For this part, you should submit a well commented listing (WCL) of MyFriendsV2 and at least 2 sample runs showing how (well) it works. Include also (of course) an explanation of the sample runs, stating how they show that your MyFriendsV2 works well.

     

  2. Create a sh shell script called AllProcesses, which creates a report file about current processes running on the system you are using. The report should include how many process are running, how many unique commands are running, how many distinct terminals are being used for these processes. After giving these statistics the report should list each user's login ID following by all the processes belonging to this ID. The report sections for different users should be separated from each other by a blank line.

    For this part, submit the same type of WCL and sample runs with explanations as you did for the previous part.

     

  3. This part continues the work you did in the previous part. After you obtained report from AllProcesses, you want to receive, via e-mail, a report of the processes belonging to a particular person (a friend or even yourself). Create another shell script called FriendProc which takes 3 arguments: an e-mail address, a login ID, and the "real name" of the person to whom the login ID belongs. It extracts from from the report produced by AllProcesses all information relevant to the login ID (the third argument). It then prepares a suitable e-mail message, including the person's "real name" and login ID in the first lines, and sends it to the e-mail address given by the first argument. Your solution may well create some intermediate file(s). If so, they should be named in such a way that you could run more than one copy of the program at the same time and they should be deleted when the program exits. You need not actually send the e-mail. It is sufficient that you echo to the screen a line giving the command that would e-mail the message to the given address.

    For this part, submit the same type of WCL and sample runs with explanations as you did for the previous parts.

     

  4. In this part, give both the awk command and a sample of its use.
    1. Write any line in which the second field contains a backslash.
    2. Write (only) the last two fields in each line, separated by a colon.
    3. Write the line number and number of fields in each line separated by a colon.
    4. Write lines longer than 66 characters.

     

  5. In this part, you will create several small (sh) shell scripts for the following requirements. You need to submit listings of your scripts and explanations about how they work including, as appropriate, suitably edited sample runs.
    1. Read in two numbers from the keyboard and print their sum.
    2. Write a shell script that given a person's uid, tells you how many times that person is logged on.
    3. Write a shell script taking a filename name as argument which lists the files in it (using ls -l piped to more) if it's a directory and shows the content of the file (using more) if it is a regular file.
    4. In many versions of UNIX there is a -i argument for cp so that you will be prompted for confirmation if you are about to overwrite a file. Write a script called cpi which will prompt if necessary.

Comments are welcome.
Current as of 7 February 2000
HTML 4.01 Checked.