Cover V07, I03
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6

mar98.tar


Listing 6: demo.sh

#!/bin/ksh
####################################################################
## demo.sh
## Demonstrates Shell classes and methods

## Create list object
.. ObjectList MyList

SYSTEMS="homer marge bart maggie lisa"

.. UnixSystem homer
.. LinuxSystem marge
.. SunSystem bart
.. UnixSystem maggie
.. SunSystem lisa

for system in $SYSTEMS
do

## insert objects into list

MyList_InsertItem $system

## Call _GetLoad() and _GetUsers() for each system through a loop

print -n "\nNumber of users logged on to $system: "
${system}_GetUsers
print -n $system"_GetLoad() being called..."
${system}_GetLoad
if (( ${system}_LAVG > 4 )); then
echo "$system has high load!!!!!!"
fi
done

## Display contents of the object list
print "ObjectList object contains the following systems:"
MyList_GetAllItems

## Use list object to call functions with _Execute
print "Checking for DiskUsage at 85% or higher...."
MyList_Execute GetDiskUsage 85
MyList_Execute ShowDiskUsage | grep !

# End of File