Listing 1: daily shell script

# Get error messages from the log /usr/adm/ras/errlog since last boot.
# If the option -t is specified,  get todays errors.
# Specify Option -s for software errors and option -h for
# hardware errors only. Otherwise hard- and software errors are reported
# Send the output to root.

# Get current year
year="`/bin/date +%y`"

# Parse the command parameters
for i in $*
do
   case $i
   in -t)      # Get todays day and month
               mon="`/bin/date +%m`"
               day="`/bin/date +%d`"
   ;; -s)      # Software related errors only
               type=Software
               flag="-d S"
   ;; -h)      # Hardware related errors only
               type=Hardware
               flag="-d H"
   ;; *)       echo "usage: $0 [-h|-s] [-tY]" 1>&2
               exit 1
   esac
done

# No -t flag specifed, get all errors since last boot time.
if [-z "$mon"]
then
   boot="`who -b`"
   set $boot
   case $5
   in Jan) mon=01
   ;; Feb) mon=02
   ;; Mar) mon=03
   ;; Apr) mon=04
   ;; May) mon=05
   ;; Jun) mon=06
   ;; Jul) mon=07
   ;; Aug) mon=08
   ;; Sep) mon=09
   ;; Oct) mon=10
   ;; Nov) mon=11
   ;; Dez) mon=12
   esac
   day=$4
fi

/usr/bin/errpt $flag -s ${mon}${day}0000${year} |
mail -s "$type Errors since $mon/$day/$year" root


