# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.
#ident	"$Header: alert.proto 1.2 89/10/10 $@(#)nlp:model/alert.proto	1.1"

-ENVIRONMENT-

cd -PWD-
ulimit -ULIMIT-
umask -UMASK-

AlErT () {
	2>&1 (
-CMD-
	) <$1 1>${TmPsTdErR} || return 1
	return 0
}

TmPsTdErR=${TMPDIR:-/usr/tmp}/`/bin/uname`$$
trap 'rm -f ${TmPsTdErR}; exit 0' 0 1 2 15

while AlErT $1
do
	if [ -INTERVAL- -le 0 ]
	then
		exit 0
	else
		TiCk=0
		while [ "${TiCk}" -lt -INTERVAL- ]
		do
			TiCk=`expr "${TiCk}" + 1`
			sleep 60
		done
	fi
done

ec=$?
if [ "${ec}" -ne 0 ]
then
	{

		echo "
One of your print service alerts failed with exit code ${ec}.
The standard output and standard error were:
	"
		cat ${TmPsTdErR}
		echo '

The alert message is:
'
		cat $1

	} | mailx -s 'Failed print service alert' -USER-
fi
