Scripts to deal with A/UX's buggy UUCP

Alexis Rosen alexis at panix.uucp
Mon Mar 11 05:48:13 AEST 1991


A few days ago I mentioned some scripts I had written to make life with A/UX's
UUCP more bearable. As I got over a dozen requests, I'm posting both scripts
here.

The first one, uupoll, will call the named system up to a specified number of
times. One key feature is that it will call again if the first connection
fails before it's done. The other feature is that it permits two-way use of
serial lines. In other words, you can use one serial port for both dial-in
and dial-out.

There is another minor bug in A/UX UUCP which will occasionally cause uupoll
to call one extra time. The bug is that UUCP writes a connection failed type
of line into the log file after a successful connection. The giveaway is that
the system it logs as failed will be named something like TM.12345.234, which
is really the name of a temporary UUCP file. (Cute, huh?) If this bug really
bothers you it's simple enough to work around. Changing the "tail -1" to
"tail -2" should do it (though I've never tried it).

Uupoll has one feature specific to my system which can safely be ignored by
most of you. I have a telebit on ttya0, which has the DCD line cut. So that
line doesn't need any of the stty modem stuff to work bidirectionally. I test
for this in my script. You can either ignore this entirely (if you don't have
a ttya0, or don't use it for UUCP), delete the "if [ line != a0 ]" line and
the corresponding "fi", or make use of it if you have a similar setup.

I have also included a second script, "uupoll.cmcl2", which I derived from the
first. Cmcl2 is our main feed, and they have several phone numbers which don't
hunt to each other, so if one number is busy, we don't get a connection. This
script employs a very ugly hack to work around that. I have four different
L.sys files, one for each cmcl2 phone number, and it simply copies each one
onto L.sys in sequence, trying each one. This works well, so I haven't bothered
to change it, but it's an awful and ugly hack. I wrote it one morning about
3AM...

If you don't like the inelegance, or you modify your L.sys frequently, try
something a little different. Put a placeholder in the L.sys where you put
the target system's phone number, and then use sed to rebuild the L.sys just
before you call. You'd need another file containing alternate phone numbers,
and so on, so I haven't bothered to rewrite it. (After all, it does what I
need...)

Note that since I call cmcl2 on my ttya0, I don't do the styy modem stuff.
Most of you will need this, and should just pull it from the uupoll script.

Once you have one or both of these scripts, you'll want them in your
/usr/lib/uucp directory, owned/grouped to uucp, and mode 554 or 550.
Set up an entry in uucp's crontab (_NOT_ root's!) to invoke them as
appropriate. You may also want to add the following lines to the uudemon.day
script, right before the uusub line near the end:
 mv Poll-Log.o Poll-Log.oo
 mv Poll-Log Poll-Log.o
 >Poll-Log
 chmod +r Poll-Log
 mailx -s "Today's polling information" uucp <Poll-Log.o

I'd really appreciate it if someone would take this and put it someplace
FTPable. If you do, keep the whole message together, and let me know.

---
Alexis Rosen
Owner/Sysadmin, PANIX Public Access Unix, NY
{cmcl2,apple}!panix!alexis
If you can't reach uucp sites: rosen at nyu.edu

---------------------------------UUPOLL------------------------------------
#!/bin/sh
# uupoll for A/UX by Alexis Rosen written 11/7/90
# Modified 3/6/91 by Alexis- cleaned up for release.
# Takes two arguments, a system name and a retry count. If the count isn't
# specified, don't retry.
# Send comments and bug reports to panix!alexis, or rosen at nyu.edu

if [ $# = 0 ] ; then echo uupoll: no system name specified ; exit 1 ; fi

PATH=/usr/lib/uucp:/bin:/usr/bin
cd /usr/lib/uucp
if egrep "^$1" L.sys >/dev/null		# look for poll system
	then :		# found it, so proceed
	else echo "uupoll: no system named $1 in /usr/lib/uucp/L.sys" ; exit 2
fi

# Get the tty id for this system. It can be one of two characters.
# This scripts assumes a valid tty designator, and will fail otherwise.
line=`awk '$1=="'$1'" {print substr($3,4,2)}' L.sys`

retry=${2-0}		# retry count is second arg, or zero if none
LOGNAME=uucp ; export LOGNAME
TZ=EST5EDT ; export TZ	# without this uucico dies in various strange ways.

while : ; do
		# kill the system status file- we're smarter than uucp is...
	rm -f /usr/spool/uucp/STST.$1
		# check to see if we're calling on ttya0. If we are, we don't
		# have to worry about a getty. If not, we need to handle the
		# getty by doing a stty -modem.
	if [ $line != a0 ] ; then
		# check to see if the line is in use. If not, use stty to
		# turn off 'modem', thereby allowing uucico to grab the line.
		# It is critical that there be a trap to turn it back on,
		# since otherwise logins on that line will be disabled.
	    if [ ! -f /usr/spool/uucp/LCK..tty$line ] ; then
		trap "stty -n /dev/tty$line modem" 0 1 2 3 15
		stty -n /dev/tty$line -modem
	    fi		# if the LCK file exists, uucico won't even try to run.
	fi
		# invoke uucico and get its process number. Then wait for the
		# uucico to exit.
	uucico -s$1 -r1 & uuproc=$! ; wait
		# undo the stty right away, if we didn't use ttya0. The trap
		# will do this for us but this frees the line for logins faster.
	stty -n /dev/tty$line modem
		# look through the last few lines of LOGFILE for entries from
		# our uucico. See if the last line indicates successful
		# completion of a conversation.
	tail -40 /usr/spool/uucp/LOGFILE | grep "(C,$uuproc" | tail -1 |
	  grep "OK (conversation complete" >/dev/null
		# if we succeeded, break out of this loop
	if [ $? = 0 ] ; then break ; fi
		# if there's already a uucico talking to this system, don't
		# bother looping. This has to go here (after the first uucico)
		# so that uucico checks for a stale lock file for us.
	if [ -f /usr/spool/uucp/LCK..$1 ] ; then break ; fi
		# if we've retried enough, quit
	if [ $retry -eq 0 ] ; then
		echo "`date '+%a %D %T'`: could not connect with $1 after ${2-0} retries" >>/usr/spool/uucp/Poll-Log ; break
	fi
	retry=`expr $retry - 1`
	sleep 600		# wait a while
done
uulog		# make sure any LTMP.$$ files get appended to the LOGFILE

---------------------------------UUPOLL.CMCL2------------------------------
#!/bin/sh
# uupoll.cmcl2- variant on uupoll written specially for cmcl2 1/30/91 by Alexis

PATH=/usr/lib/uucp:/bin:/usr/bin
cd /usr/lib/uucp
LOGNAME=uucp ; export LOGNAME
TZ=EST5EDT ; export TZ
finish=false
for xxx in 1 1 1 1 ; do
    for sysfile in L.sys.? ; do
		# kill the system status file- we're smarter than uucp is...
	rm -f /usr/spool/uucp/STST.cmcl2
		# copy appropriate L.sys.? file to L.sys
	cp $sysfile L.sys
		# invoke uucico and get it's process number. Then wait for the
		# uucico to exit.
	uucico -scmcl2 -r1 & uuproc=$! ; wait
		# look through the last few lines of LOGFILE for entries from
		# our uucico. See if the last line indicates successful
		# completion of a conversation.
	tail -40 /usr/spool/uucp/LOGFILE | grep "(C,$uuproc" | tail -1 |
	  grep "OK (conversation complete" >/dev/null
		# if we succeeded, break out of this loop
	if [ $? = 0 ] ; then
	    echo "`date '+%a %D %T'`: Cmcl2 succeeded with $sysfile" >>/usr/spool/uucp/Poll-Log ; finish=true ; break
	fi
		# if there's already a uucico talking to this system, don't
		# bother looping. This has to go here (after the first uucico)
		# so that uucico checks for a stale lock file for us.
	if [ -f /usr/spool/uucp/LCK..cmcl2 ] ; then
	    echo "`date '+%a %D %T'`: already connected to cmcl2" >>/usr/spool/uucp/Poll-Log ; finish=true ; break
	fi
	sleep 60		# wait a while
    done
    if [ $finish = true ] ; then break ; fi
    sleep 600
done
if [ $finish = false ] ; then
    echo "`date '+%a %D %T'`: failed to connect to cmcl2" >>/usr/spool/uucp/Poll-Log
fi
uulog		# make sure any LTMP.$$ files get appended to the LOGFILE



More information about the Comp.unix.aux mailing list