:
# @(#)errprint.sh 5.3b of Jan 27, 1988
:

# This shell script runs the errstrip awk script on the error file for a
# given date.  A date may be entered on the command line as mm dd, mm-dd, 
# mm/dd, or month dd.  If no date is specified, the current date is used.

OFS="$IFS"
IFS="$IFS/-"
set `echo $*` >/dev/null
IFS=$OFS
if test $# -eq 0 
then
# use current date for error file
	month=`date +%m`
	day=`date +%d`
elif [ $# -eq 2 ]
then
# use specified date for error file
	month=$1
	day=$2
	case $month in 
		[Jj]an*)	month=01 ;;
		[Ff]eb*)	month=02 ;;
		[Mm]ar*)	month=03 ;;
		[Aa]pr*)	month=04 ;;
		[Mm]ay*)	month=05 ;;
		[Jj]un*)	month=06 ;;
		[Jj]ul*)	month=07 ;;
		[Aa]ug*)	month=08 ;;
		[Ss]ep*)	month=09 ;;
		[Oo]ct*)	month=10 ;;
		[Nn]ov*)	month=11 ;;
		[Dd]ec*)	month=12 ;;
		[1-9])		month=0$month ;;
		[0-9][0-9])	if [ $month -lt 1 ] || [ $month -gt 12 ]
				then
					echo Invalid month: $month
					exit 1
				fi ;;
		*)		echo Invalid month: $month
				exit 1 ;;
	esac

	case $day in
		[1-9])		day=0$day ;;
		[0-9][0-9])	if [ $day -lt 1 ] || [ $day -gt 31 ]
				then
					echo Invalid day: $day
					exit 1
				fi ;;
		*)		echo Invalid day: $day
				exit 1 ;;
	esac
else
# wrong number of arguments on command line
	echo usage: $0 [mm-dd]
	exit 1
fi
# find the error file and display it
errfile=/usr/adm/streams/error.$month-$day
if [ -f $errfile ]
then
	awk -f /usr/lib/errstrip.awk $errfile | more
else
	echo File $errfile not found
	exit 1
fi

