call back
Eelco van Asperen
evas at euraiv1.UUCP
Wed Jul 20 01:26:58 AEST 1988
in article <301 at eurtrx.UUCP>, evas at 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 at eurtrx / mcvax!eurtrx!evas #include <inews/filler.h>
earn/bitnet: asperen at hroeur5 #include <stdjunk.h>
-------------------------------------------------------------------------
# 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
More information about the Comp.unix.questions
mailing list