[comp.unix.questions] UUCICO exit status...

bak@csd_v.UUCP (Bruce) (11/22/87)

Perhaps I am reinventing the wheel here, but I am trying to write
a utility that polls a system and continues to retry every so often
( default 1 hour intervals ) until a successful connection is established.

I am doing this because if I just issue a 

	$ uucico -r1 sysname &

or some equivalent like uusub, etc., the connection is only tryed three times 
if the destination is busy and then the poll goes away.

I would like a utility that continues to exec uucico and then reschedule
itself until uucico successfully connects to the destination system.  My
problems are

	(1) is this really necessary or is there some uucp facility ( not 
		HONEYDANBER ) which incorporates this function and

	(2)	if not, how do I tell whether or not uucico has successfully
		connected to the target system.  Uucico seems to exit 0 regardless
		of the circumstances.
		
Any help would be appreciated.
-- 
Bruce Kern                                      | uunet!swlabs!csd_v!bak
Computer Systems Design                         | 1-203-270-0399
29 High Rock Rd., Sandy Hook, Ct. 06482         | This space for rent.

dhesi@bsu-cs.UUCP (Rahul Dhesi) (11/23/87)

In article <134@csd_v.UUCP> bak@csd_v.UUCP (Bruce) writes:
>Perhaps I am reinventing the wheel here, but I am trying to write
>a utility that polls a system and continues to retry every so often
>( default 1 hour intervals ) until a successful connection is established.

If you're using 4.3BSD, use the "uupoll" command to queue a null
request, and invoke uucico hourly from cron.

If you're using System V Release 2, create a uupoll script that
includes the following lines:

     pollfile=/usr/spool/uucp/C.${system}ACPOLL
     touch $pollfile && chmod a+w $pollfile

Here, the variable "system" contains the name of the system for which
you wish to queue a null request.

(My uupoll script actually validates the system name against those
returned by the uuname command, so a mistyped system name doesn't cause
trouble.)

Invoke this uupoll script when you want to queue a null request.  Then
whenever uucico is invoked it will attempt to call the system, and will
keep on doing so until the connection is successful.

Also, since you will be invoking uucico hourly, you may wish to add the
-r flag to all uucp requests, so they are all queued instead of
invoking uucico immediately.  (This flag may be undocumented for some
commands.)  If you are using smail, add the -r flag to where it calls
uux.

I don't know how System V Release 3 handles this.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi

zeeff@b-tech.UUCP (Jon Zeeff) (11/27/87)

In article <134@csd_v.UUCP> bak@csd_v.UUCP (Bruce) writes:
>Perhaps I am reinventing the wheel here, but I am trying to write
>a utility that polls a system and continues to retry every so often
>( default 1 hour intervals ) until a successful connection is established.
>

I found that the most reliable way to tell if a connection has taken place
is uusub (SysV.2 w/o HDB).  So you get something like:


# Execute this script just after midnight with "poll time sites1 site2 .."
# -- Jon Zeeff  (umix!b-tech!zeeff)

. /etc/TIMEZONE

quit=$1
shift

today=`date +%d`

# loop until the quit time
while test `date +%H` -le $quit
do
   
   for j in $*
   do
      # trim to 6 chars
      i=`expr "$j" : '\(.\{1,6\}\).*'`
   
      laston=`uustat -M$j`
      laston=`expr "$laston" : '.*/\([0-9].\).*' 2> /dev/null`
   
      if test $laston -ne $today 2> /dev/null
         then

         /usr/lib/uucp/uucico -r1 -s$j
         status=$?

	 # Code to handle the case where the uukill daemon noticed that
	 # disk space was running out and killed incoming uucp connections
	 # if it was killed, then disk is full and we shouldn't call for awhile
         if test status -eq 15 
         then
            sleep 5000
         fi
   
         # wait in case uuxqt is going to trigger something
         sleep 40
      fi
   done

   # Wait a while before trying again
   sleep 1000
done


-- 
Jon Zeeff           		Branch Technology,
uunet!umix!b-tech!zeeff  	zeeff%b-tech.uucp@umix.cc.umich.edu

giebelhaus@hi-csc.UUCP (Timothy R. Giebelhaus) (11/29/87)

I use this script.  It works very well for me.  It also calls again if
the call was not finished (failed a normal termination).  One day I
plan to change it just a bit so that if it does turn out the call is
already in progress when the script starts, it checks to see if the
call terminated normally.  Now, if the call was already made by the 
remote host or uu.hourly, it just drops through.

#! /bin/sh
#
# Call uunet for news
newssystem=uunet
uucico -r1 -s${newssystem}
#
# Try to call again a few more times if I have to
# sleep first to be sure the STST and LCK files are stable.
sleep 60
ststfile=/usr/spool/uucp/STST.${newssystem}
lckfile=/usr/spool/uucp/LCK..${newssystem}
maxtries=aaaaaaaaaaaaaaaa
tries=a
while test -f $ststfile -a $tries != $maxtries -a ! -f $lckfile
	do
	echo "Failed, STST = `cat $ststfile`; tries = $tries" | mail root
	sleep 900
	tries=${tries}a
	rm $ststfile
	uucico -r1 -s${newssystem}
	sleep 60
	done
# Notify me if the news did not finish
if test $tries = $maxtries
	then
	echo "Failed to call $newssystem for news" | mail root
	fi
# Notify me if the news was already running.
if test -f $lckfile
	then
	echo "LCK file exists.  STST = `cat $ststfile`" | mail root
	fi
-- 
---------------------------------
UUCP: {uunet, ihnp4!umn-cs}!hi-csc!giebelhaus
ARPA: hi-csc!giebelhaus@umn-cs.arpa
Nobody I know admits to sharing my opinions.  I don't even have a pet.