Cover V04, I04
Article
Figure 1
Figure 2
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5

jul95.tar


Listing 1: numpager

#!/bin/sh
#
#  Program:    numpager
#  Author:     Mark J. McDonagh
#  Version:    1.1
#  Date:       07/10/94
#  owner = root, group = adm, permissions = -rwxr-xr-x
#
#  Description:
#
#    This script allows users to send a numeric page to a pre-defined
#  group of people based on a lookup table of names and pager numbers.
#
#    This script was primarily written as a system monitoring tool, but
#  can also be used as an automated way to page users, systems staff,
#  sales staff, etc.
#
#    The script looks for 2 parameters, 1st the name of the person that
#  the page is being sent to and 2nd the numeric messagewhether it is an
#  error code from a script the system is monitoring or if it is a phone
#  number of the person placing the page so that the recipient can call
#  them back.
#
#  Files: .UNIX_ONCALL   name of person handling UNIX problems
#         .PC_ONCALL     name of person handling PC problems
#         .PAGER_LIST    list of names and pager numbers (seperate by
#                        tabs)
#
#  Variables:  UNIXSA    use as 1st parameter to page UNIX Administrator
#              PCSA      use as 1st parameter to page PC Administrator
#
#  Example:    numpager UNIXSA 001
#
#         This would call the UNIX on call person and display 001 as
#         the error code on his/her pager.
#
#  Example:    numpager mark 5551212
#
#         This would call mark and display 5551212 as
#         the phone number to call on his pager.
#
#
if [ "$#" -ne 2 ]
then
echo "Incorrect number of arguments - needs 2 arguements as follows:"
echo "Usage:  numpager    person to page    error code and/or phone # to call"
sleep 5
exit 1
fi
PAGPERSON=$1
PAGERCODE=$2
PAGFILE="/usr/local/bin/.PAGER_LIST"
if [ "$1" = UNIXSA ] ; then
PAGPERSON=`cat /usr/local/bin/.UNIX_ONCALL`
fi
if [ "$1" = PCSA ] ; then
PAGPERSON=`cat /usr/local/bin/.PC_ONCALL`
fi
cat $PAGFILE | grep $PAGPERSON > /dev/null 2>&1
if [ "$?" = 0 ]
then
PAGERNUM="`cat $PAGFILE | grep $PAGPERSON | awk '{print $2}'"
else
echo "Unable to send Page to: $PAGPERSON"
echo "Name of Person to be Paged is not valid as listed."
sleep 5
exit 1
fi
expr $PAGERCODE + 1 > /dev/null 2>&1
if [ "$?" = 0 ]
then
STATUS="BAD"
while [ $STATUS = "BAD" ]
do
#echo "~.\013" | cu -d -s2400 $PAGERNUM-----$PAGERCODE
echo "~.\013" | cu -s2400 $PAGERNUM-----$PAGERCODE > /dev/null 2>&1
if [ "$?" = 0 ]
then STATUS="OK"
else STATUS="BAD"; echo "Phone Line Busy - Re-trying."; sleep 15
fi
done
else
echo "Unable to send Page to: $PAGPERSON"
echo ""
echo "Error Code and/or Phone Number to display MUST be"
echo "Numeric only."
sleep 5
exit 1
fi