#!/bin/ksh # $Id: oncall.sh,v 1.2 1997/11/23 22:55:27 ksb Exp $ # # Determin who's pager gets beeped (who is on call?) output the line of # the person whose week it is. (wam) # The input file data file has lines like # # comments # who pager-pin # whoelse pager-pin # we round-robin through the list unless one is prefixed with the # string "ONCALL:" (in which case we always pick them). PATH=/usr/bin:$PATH FILE=${1:-/usr/local/lib/oncall} WEEK=${2:-`date +"%W"`} # $1 is the data file to scan for oncall lines # $2 forces the week number if the caller wants to ask who is on-call # for that week (like next week). # Trap a forced oncall person first (viz. ONCALL: person pager). if PERSON=`grep '^ONCALL:' $FILE` then set _ $PERSON shift shift echo $@ exit 0 fi # else just cycle through them by week NUM=`egrep -v '^#|^[ ]*$' $FILE | wc -l` egrep -v '^#|^[ ]*$' $FILE | sed -n -e `expr 1 + \( $WEEK % $NUM \)`p exit 0