[comp.unix.shell] UUCP Script Problems

davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (09/16/90)

In article <393@tygra.UUCP> cat@tygra.UUCP (CAT-TALK Maint. Account) writes:
| I'm using the following script to call one of my UUCP feeder
| sites. The idea is that it should continue to retry the call
| until the call completes successfully. (There is a problem with
| noisy phone lines and the antiquated Merit Network which cause
| calls to fail in midstream):

  I would suggest several changes. This is the script you showed:

| # !/bin/csh
| #
| /usr/lib/uucp/uucico -r1 -Ssharkey
| while ($status != 0)
|    sleep 300
|    /usr/lib/uucp/uuxqt
|    /usr/lib/uucp/uucico -r1 -Ssharkey 
| end

  I am not a csh expert, so let me offer a /bin/sh solution:

while true
do
  { sleep 300 & /usr/lib/uucp/uuxqt; wait $!; }
  /usr/lib/uucp/uucico -r1 -Ssharkey && break
done
/usr/lib/uucp/uuxqt

  There are two bits of trickyness here... the first is that this is an
endless loop, broken only when the uucico executes with good status and
the && lets the break take effect.

  Second, the use of { } bracketing allows the five minute sleep and the
uuxqt to run in parallel, ending when both are finished. The $! makes it
wait for only the sleep, in case this is part of some other stuff you
run and there are other process started.

  Finally, running uuxqt one last time after uucico is not tricky, just
standard practice.

  Oh, since this is really a shell question I added the shell group to
the distribution, if you followup please edit out any group which does
not apply to your posting.
-- 
bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc and 80386 mailing list
"Stupidity, like virtue, is its own reward" -me