Article Listing 1 Listing 2 oct2005.tar

Listing 2 assert_attributes_2

# Listing 2: assert_attributes_2
#!/bin/ksh

verbose=FALSE

while getopts v optarg
do
    case $optarg in
    v)
        verbose=TRUE
        ;;
    esac
done

shift $(($OPTIND-1))

packages=$@
for package in $packages
do
    if ! pkginfo $package
    then
        continue
    fi
    error_file=/tmp/${package}.errors
    > $error_file
    pkgchk -a $package 2> $error_file
    size=$(du $error_file | cut -f1)
    if (( $size > 0 ))
    then
        if [[ TRUE = $verbose ]]
        then
            cat $error_file
        fi
        pkgchk -a -f $package
        category=$(basename $0)
        message="file attributes have changed"
        cat $error_file | \
        sudo -u monitor /opt/monitor/bin/create_alert_file -p med \
        -c "$category" -s "$message"
    fi
    rm -f $error_file
done
# End Listing 2