Topical Information

The purpose of this programming assignment is to test your ability to create [bash] shell scripts to solve problems not exactly solved by common *nix tools.

Program Background

First make sure you've read all of Chapters 8 and 10 from the *nix book.

Program Information

One task often desired by *nix users and administrators alike is that of process tracking. In other words, what users are running what processes on the system right now?

You'll create a script in bash shell to list all processes currently running grouped by the processes' owners. If given a particular user(s), just list the processes that user has running.

If you are not given a particular user(s), however, create a menu of the users who own currently running processes with an 'all' option added at the end of the menu and prompt the script executer for whose processes to list. (Also allow them to quit without selecting anyone — maybe they just wanted to see who was running anything currently...*shrug*)


So, for example, should your script be called with a particular user, you might see a list like this:

$ proclist jjames
jjames is currently running:
        ssh
        gvim
        CPP
        g++

As a special case, watch out for users who aren't currently running any processes!

$ proclist notauser
notauser is currently running:
        NOTHING

And, perhaps even special treatment of the current user:

$ proclist `whoami`
YOU are currently running:
        ssh

(Although the login status/process doesn't seem to be handled entirely consistently on mars. *shrug*)

Notice that the script doesn't list itself to the executer since we assume they know they are running it. *smile* However, if someone else where running the script, it would appear in their list:

$ proclist dkobler
dkobler is currently running:
        ssh
        proclist

A sample of use from the menu form might be:

$ proclist

Processes are currently being run by:
    1) dkobler
    2) jjames
    3) YOU
    4) a_notherstudent
    5) ALL
Whose processes to list?  _

Use as many built-in tools as you can to collect the necessary information from around the system and process it. If you cannot think of a tool, check Part VI of your *nix book first before coding out lots of processing in bash shell. (Trust me...)

I would suggest that you'll be using at least ps, grep, whoami, and cut. (But that is just off the top of my head. Others may also prove useful! Don't sell a good tool short just because the teacher didn't mention it... *grin*)

Although ps is your main tool here, keep in mind that not all ps implementations are created equal. Try to use as common a subset of command-line options and available information as possible. (You can generally find man pages for other *nix implementations online even if you don't have access to a system running that flavor of *nix. *smile*)


Also take the following command-line options:

This assignment is (Level 5).

Options