Listing 4 filter
#!/bin/ksh
#***************************************************
# Listing 4:
# filter
#
# Description:
#
# This script creates a filtered snapshot file. This
# filtered file is used during a filtered compare.
#
# Author: John Spurgeon (john.p.spurgeon@intel.com)
#
#***************************************************
if [ -z "$ENTRAP" ]
then
$(dirname $0)/entrap
exit 0
fi
FILTER_DIR=$FILTER_ROOT/$CONFIG_NAME
while getopts f:h OPTION
do
case "$OPTION"
in
f) FILTER_DIR=$FILTER_ROOT/$OPTARG ;;
h) echo "$(basename $0) [-f filter_name] snapshot"
exit 0 ;;
\?) exit 1 ;;
esac
done
if [ "$OPTIND" -gt "$#" ]
then
echo "[$(basename $0)] Error: Missing snapshot label!" >& 2
exit 1
fi
shift $(($OPTIND - 1))
SNAPSHOT_NAME=$1
SNAPSHOT_DIR=$SNAPSHOT_ROOT/$SNAPSHOT_NAME
if ! [ -d $FILTER_DIR ]
then
mkdir $FILTER_DIR
if ! [ -d $FILTER_DIR ]
then
echo "[$(basename $0)] Error: Failed to create filter directory!" >& 2
exit 1
fi
fi
while read DIR FILE
do
if ! [ -f $SNAPSHOT_DIR/$FILE ]
then
echo "[$(basename $0)] Warning: $SNAPSHOT_DIR/$FILE does not exist." >& 2
continue
fi
if ! [ -f $FILTER_DIR/$FILE ]
then
touch $FILTER_DIR/$FILE
fi
cat $SNAPSHOT_DIR/$FILE | $FILTER $FILTER_DIR/$FILE > $SNAPSHOT_DIR/$FILE.f
done < $CONFIG_FILE
#!/bin/ksh
|