CS160B lab6-online Boyd

Lab 6 (online) - pinfo 5 points (plus possible 5 points of extra credit)

Note: Lab6 finshes implementing pinfo, which is begun in lab5 as xpinfo. Refer to lab5 for more info.

Description

In Lab 6 we will finish the implementation of pinfo, starting with xpinfo, which we created in lab5, by adding a few loops. Here are the features you must add to pinfo:

The information on the extra credit part is below.

Here is sample output from a version of pinfo. In this example, the user's home directory was searchable (executable) for everyone, his .plan file did not exist, and the .project file had the incorrect permissions. He also had a problem getting a unique title (the user-entered text is bold-italic.)

-bash$ pinfo

Welcome to pinfo - Set your finger personal information

pinfo:ERROR: The ~/.plan file does not exist.

Please type in the ~/.plan now. Type control-D to finish

To teach what I know of Unix and Linux and

learn the rest with my students.

< --- control-D was typed here

Your ~/.project file must allow r access for all users.

Do you want me to change its permissions?(y/n): yes

Please enter y or n

Do you want me to change its permissions?(y/n): y

Enter your title: Lord of Peanut Butter

Sorry, that title is already in-use. Try another.

Enter your title: Unix/Linux Instructor

Enter your location: L413


Extra Credit

For the extra credit you must implement the following function

makereadable xxx

makereadable will check that file xxx (its single argument) is world-readable. If not, it will ask the user's permission to make xxx readable. If the user does not allow the permissions to be changed OR the file's permissions cannot be changed (chmod fails), makereadable returns with a failure status. If xxx already is world-readable or makereadable successfully makes it world-readable, makereadable returns with a success status. You may want to make use of askyn in your function makereadable.

You should call your function twice, once for .project and once for .plan. Of course you must test makereadable's exit status when it returns and exit if it failed.

For full credit makereadable must be free of side-effects (not use global variables) and have a few lines of documentation.

If you do the extra credit, you must indicate you did the extra credit as a comment at the beginning of your shell script like this:

# EXTRA CREDIT

To submit

Submit a copy of your shell script online for grading by pasting it into the assignment submission box. Then run the transfer program on hills to place a machine-readable copy of your shell script (which must be named pinfo ) in your share directory as in all assignments like this:

/pub/cs/gboyd/cs160b/bin/transfer pinfo

Submit a single copy of pinfo whether you did the extra credit or not. If you do the extra credit, make sure you indicate that in the beginning of your shell script as indicated above.

lab6-online CS160B Page 2 of 2

This document was produced with free software: OpenOffice.org on linux.