[net.unix] calling a terminal

hartley@uvm-cs.UUCP (Steve) (09/04/85)

Here is the quick and dirty script (please, no flames about using csh, I am
just a professor) I use to have the VAX (4.2 BSD) call me at home.  It works
with a DEC DF03 modem only (/dev/ttyi1), and observes the tip/uucp locking
protocol.  I have my own cron and crontab, and schedule calls from there.  The
Burlington area phone company has gone to measured service for everybody.

	#! /bin/csh -f
	# call a terminal, run setuid to root, executable from group tippers
	set path=(/bin /usr/bin /usr/ucb /etc)
	setenv PATH /bin:/usr/bin:/usr/ucb:/etc
	onintr -
	echo " Calling $1 at `date` ($$)" >>/usr/spool/uucp/LOGFILE
	set status=0
	csh -f <<-EOF-
	set noclobber
	cat /dev/null >/usr/spool/uucp/LCK..ttyi1
	-EOF-
	if ($status == 0) then
	ed /etc/ttys <<DONE1
	/ttyi1/s/0f/1f/
	w
	q
	DONE1
	sleep 1
	kill -1 1
	sleep 1
	#DEC DF03 modem only
	echo "$1" >/dev/ttyi1
	sleep 180
	set HERE=`w | grep -c ttyi1`
	if ($HERE) then
	echo " Call to $1 succeeded ($$)" >>/usr/spool/uucp/LOGFILE
	else
	echo " Call to $1 failed ($$)" >>/usr/spool/uucp/LOGFILE
	endif
	while ($HERE)
	sleep 180
	set HERE=`w | grep -c ttyi1`
	end
	sleep 1
	ed /etc/ttys <<DONE2
	/ttyi1/s/1f/0f/
	w
	q
	DONE2
	sleep 1
	kill -1 1
	sleep 1
	chown uucp /dev/ttyi1
	chmod 660 /dev/ttyi1
	#chgrp daemon /dev/ttyi1
	rm /usr/spool/uucp/LCK..ttyi1
	echo " Call to $1 done at `date` ($$)" >>/usr/spool/uucp/LOGFILE
	else
	echo " But the dialer is LOCKED ($$)" >>/usr/spool/uucp/LOGFILE
	endif
-- 
"If that's true, then I'm the Pope!"			Stephen J. Hartley
USENET:	{decvax,ihnp4}!dartvax!uvm-gen!uvm-cs!hartley	University of Vermont
CSNET:	hartley%uvm@csnet-relay				(802) 656-3330, 862-5323