#!/bin/ksh # # skypage.sh: command line paging facility # # Author: David Currier, IBM Global Services T/L 376-5720 # # Discription: # This program will page people from a unix command line, # by pin number, name or team/project. If paging by name # or team/project, an entry must be made in the skypage.dat # table for each individual. # # Benifits: # 1) More reliable then e-mail, which doesn't work at this time. # 2) Instant notification of page receipt. # 3) Group (team/project) paging. (ie. cfe, patent) # 4) Can be called from scripts for instant notification. # 5) Can be called from cron for system monitoring. # # ## SET VARIABLES ############################# pagerfile=/dfs/patent/admin/skypage.dat pagerfile=/afs/almaden.ibm.com/u/jasper/bin/skypage.dat logfile=/dfs/patent/admin/skypage.log logfile=~/skypage.log usage() { ########################### print print "skypage: ${2}" print "usage: skypage name|team|pin \"message text\"" print print "skypage.dat - Contains list of pager pin numbers, names and teams" print exit ${1} } # end usage checkpin() { ############################ if [ $(grep -i -c ${pin} ${pagerfile}) -eq 0 ] ; then usage 2 "${pin} not found in ${pagerfile}" fi } # end checkpin getpins() { ############################# if print ${pin} | grep -q "[A-z]" ; then checkpin for i in $(grep -i -w ${pin} ${pagerfile} | awk '{print $1}') ; do list=$(print ${list} ${i}) done else list=${pin} fi } # end getpins processmsg() { ############################# message=$(print ${message} | colrm 255) messageout=`print ${message}|sed 's/%/percent/g s/+/%2b/g s/ /+/g s/&/and/g s/\`//g'` } # end processmsg sendpage() { ############################# date +"|%D|%T|${pin}|${pinno}|${message}|" >> ${logfile} print "Paging ${pin} (${pinno}) with [${message}]..." pagecmd="GET /Paging/page.cgi?success_url=&to=${pinno}&pager=1&message=${messageout}" (sleep 1; \ echo ${pagecmd}; \ sleep 1)|/local/bin/rtelnet www.skytel.com 80|grep TITLE|sed 's/<.[^<>]*>//g' | tee -a ${logfile} #print "DEBUG paging ${pinno} ${messageout}" sleep 2 } # end sendpage ####### MAIN ############################## if [ $# -eq 2 ] ; then pin=${1} message=${2} else usage 1 "invalid arguments" fi getpins processmsg for pinno in ${list} ; do sendpage done