#!/bin/sh
CDBS_TOP=${CDBS_TOP:-/data/cdbs1/tools/}
export CDBS_TOP

. ${CDBS_TOP}/util/defines.sh
export CDBS_DB CDBS_SERVER

dir=`pwd`
cd $CDBS_TOP/src/check_cdbs
echo "starting check_cdbs "
echo "database " ${CDBS_DB?"CDBS_ERROR: CDBS_DB is undefined"}
echo "server " ${CDBS_SERVER?"CDBS_ERROR: CDBS_SERVER is undefined"}
date
dn=`delivery_number.s | awk -f awk.dn`

if test $# -lt 1
then
check_cdbs.s $dir/check_cdbs_$dn.out
else
check_cdbs.s $dir/check_cdbs_$dn.out $1
fi
echo " "
echo "output file check_cdbs_$dn.out created"
nwarn=`grep 'WARN' $dir/check_cdbs_$dn.out | wc -l` 
if test $nwarn -gt 0
then
   echo "$nwarn warning(s): see output file check_cdbs_$dn.out"
else
   echo "No warnings."
fi
nerr=`grep 'ERROR' $dir/check_cdbs_$dn.out | wc -l` 
if test $nerr -gt 0
then
   echo "$nerr error(s): see output file check_cdbs_$dn.out"
   exit 1
else
   echo "No errors."
   exit 0
fi






