Question: Your assignment is to write a shell script named rpsm.sh. The script reports and prints (to stdout) selected storage management information. Think of it as

Your assignment is to write a shell script named rpsm.sh. The script reports and prints (to stdout) selected storage management information. Think of it as RePort Storage Management. Clever, eh?

The easy way to describe what the script needs to do is to look at what it should display in the case where you provide incorrect parameters, or in the case where you provide -h for help:

Usage: ./rpsm.sh

Reports selected information about specified directory tree.

Options:

-h Print this message

-v Print script version information

-u Find and list all files with setuid set, all owners

-g Find and list all files with setgid set, all owners

-w Find and list all files that are world-writable

-b Find and list all files whose size is at least 10M

-d Report directory disk usage

-i Report information about filesystem

-a All of the above (except -h and -v)

There are files which match these criteria on the machine loki.ist.unomaha.edu in the directory /home/abcdef/IASC3350. In other words, theres a file larger than 10M, theres a few files that are world-writable, and so on. It might be easier to test your script against this directory instead of / for example because it will be much faster and you will not get a bunch of permission denied messages.

Most of the options above are self-explanatory, but some are not, so let me provide examples for the latter case. The -d option should produce sorted output just like this:

abcdef@loki:~$ ./rpsm.sh d /home/abcdef/IASC3350

4 /home/abcdef/IASC3350/Perms

8 /home/abcdef/IASC3350/EnvDemo

12 /home/abcdef/IASC3350/BigFiles

24 /home/abcdef/IASC3350/SomeSetgids

24 /home/abcdef/IASC3350/SomeSetuids

76 /home/abcdef/IASC3350

The -i option shows me information about the filesystem holding the directory I am asking about. (Hint: look at the df command.) It does not give me all of the information but it should look just like this:

abcdef@loki:~$ ./rpsm.sh i /home/abcdef/IASC3350

Filesystem Type Use% Mounted on

prog.ist.unomaha.edu:/home nfs4 52% /home

Again, you will want to figure out how to get the information and then also how to cut it up. Heres another example:

abcdef@loki:~$ ./rpsm.sh id /etc

Filesystem Type Use% Mounted on

/dev/mapper/loki-root ext4 28% /

4 /etc/apache2/sites-enabled

4 /etc/apparmor.d/disable

4 /etc/apparmor.d/force-complain

4 /etc/apparmor.d/tunables/multiarch.d

4 /etc/apparmor/init/network-interface-security

Youll note that the output for id versus di would be different because of the order of the command line arguments. Also note that you need to handle for instance - id as the same as i d. We cover getopts in this class use it!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!