Xref: utzoo comp.sources.d:2514 comp.sources.wanted:4610 comp.unix.questions:8332 comp.dcom.modems:2107 Path: utzoo!attcan!uunet!mcvax!eurtrx!euraiv1!evas From: evas@euraiv1.UUCP (Eelco van Asperen) Newsgroups: comp.sources.d,comp.sources.wanted,comp.unix.questions,comp.dcom.modems Subject: Re: call back Message-ID: <717@euraiv1.UUCP> Date: 19 Jul 88 15:26:58 GMT References: <301@eurtrx.UUCP> Organization: Erasmus University EF/AIV,Rotterdam,Netherlands Lines: 155 in article <301@eurtrx.UUCP>, evas@eurtrx.UUCP (Eelco van Asperen) says: > > If your machine has 'cu' (call Unix), then it's simple; I've got a > small script that looks up users in a callback-database, locates a > free dialer and starts the dial-back. Shout if you want it. > Since I made this offer, my mailbox has been flooded with requests for this script so I've decided to post it. I don't consider this a very elegant script but then it does what it's supposed to do. Eelco van Asperen. ------------------------------------------------------------------------- uucp: evas@eurtrx / mcvax!eurtrx!evas #include earn/bitnet: asperen@hroeur5 #include ------------------------------------------------------------------------- # This is a shar archive. Extract with sh, not csh. # This archive ends with exit, so do not worry about trailing junk. # --------------------------- cut here -------------------------- PATH=/bin:/usr/bin echo Extracting callback sed 's/^X//' > callback << '+ END-OF-FILE 'callback X#! /bin/sh X# X# callback -- a call-back facility for aiv-staff members. X# X# usage: callback [baud [waittime] ] X# X# v1 03-10-86 Eelco van Asperen X# v2 06-07-88 Cleaning-up X# X# this is the file where user/telno data are stored: X# XCALLDBS="/usr2/aiv/admi/callback.dbs" X# X# first get callers name: X# XHISNAME=`who am i | cut -f1 -d" " -s` X# X# now see if he/she is in the callback-database: X# XHISENTRY=`grep ^$HISNAME: $CALLDBS` XPHONENUM=`echo $HISENTRY | cut -d":" -f2 -s` X# Xif [ -z "$PHONENUM" ] Xthen X echo "Your name is not in the call-back database; contact your sysop." X exit 1 Xelse X echo "Your phone-number: "$PHONENUM Xfi Xif [ -n "$1" ] Xthen X BAUD=$1 Xelse X BAUD=`echo $HISENTRY | cut -d":" -f3 -s` Xfi Xif [ -z "$BAUD" ] Xthen X # system default baudrate: X BAUD=1200 Xfi XWAIT=15 Xif [ "$2" != "" ] Xthen X # X # how long should 'cu' wait for a free dialer ? X # (in minutes) X # X WAIT=$2 Xfi X# X# Parse the /usr/lib/uucp/Devices-file to find list of dialers; X# XTMPFILE=/tmp/cback.$$ Xtrap 'rm $TMPFILE' 0 1 15 XDEBUG=9 X Xawk -F" " ' XBEGIN { dialers=""; X speeds=""; X } X/^ACU/ { if ($4 == reqspeed) X dialers = dialers " " $2; X else if (speeds == "" || index(speeds,$4) == 0) { X speeds = speeds " " $4; X } X } XEND { if (dialers == "") { X print "echo \"Sorry, there are no dialers at",reqspeed,\ X "baud available on this system.\""; X print "echo \"Dialers are available at the following speeds:\"" X print "echo \" ",speeds,"\"" X print "exit 1"; X } X else { X print "for i in",dialers X print "do" X print " if [ ! -f /usr/spool/locks/LCK..$i ]" X print " then" X print " echo \"Found free dialer $i\"" X print " exit 0\n"\ X " fi\n"; X print "done" X X print "echo \"Sorry, all dialers are currently locked\""; X print "echo \"Start callback anyway (y,n) ? \\c\""; X print "read answer"; X print "if [ \"$answer\" != \"y\" ]"; X print "then"; X print " exit 1"; X print "fi"; X print "exit 0"; X } X } X' reqspeed=$BAUD /usr/lib/uucp/Devices >$TMPFILE X Xsh $TMPFILE Xif [ $? != 0 ] Xthen X exit 1 Xfi Xtrap "" 0 1 15 Xrm -f $TMPFILE X# X# start dialing: X# X(nohup ct -w${WAIT} -s${BAUD} -x${DEBUG} 0-${PHONENUM})& Xecho "Dial-back started..." Xexit 0 + END-OF-FILE callback chmod 'u=rwx,g=rx,o=rx' callback set `sum callback` sum=$1 case $sum in 28879) :;; *) echo 'Bad sum in 'callback >&2 esac echo Extracting callback.dbs sed 's/^X//' > callback.dbs << '+ END-OF-FILE 'callback.dbs X# X# format: X# loginname:phonenumber[:baudrate] X# Xevas:01234-87654:1200 Xdumbuser:123456 + END-OF-FILE callback.dbs chmod 'u=rw,g=r,o=' callback.dbs set `sum callback.dbs` sum=$1 case $sum in 6774) :;; *) echo 'Bad sum in 'callback.dbs >&2 esac exit 0