Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the script I need to write: Your assignment is to write a shell script named rpsm.sh. The script reports and prints (to stdout)

This is the script I need to write: 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 (options) (directory)

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)

Test the script against a directory where you won't 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 (just an example):

anyuser@whatever:~$ ./rpsm.sh d /home/anyuser/anydirectory

4 /home/anyuser/anydirectory/Perms

8 /home/anyuser/anydirectory/EnvDemo

12 /home/anyuser/anydirectory/BigFiles

24 /home/anyuser/anydirectory/SomeSetgids

24 /home/anyuser/anydirectory/SomeSetuids

76 /home/anyuser/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 (just an example):

anyuser@whatever:~$ ./rpsm.sh i /home/anyuser/anydirectory

Filesystem Type Use% Mounted on

prog.ist.somecollege.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:

anyuser@whatever:~$ ./rpsm.sh id /etc

Filesystem Type Use% Mounted on

/dev/mapper/whatever-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

(more...)

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 id.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions