zsh-workers
 help / color / mirror / code / Atom feed
* Re: commands sometimes don't execute (solved)
       [not found] <3938.9507181044@pyro.swan.ac.uk>
@ 1995-07-19  4:55 ` Dave
  0 siblings, 0 replies; only message in thread
From: Dave @ 1995-07-19  4:55 UTC (permalink / raw)
  To: P.Stephenson; +Cc: zsh-list, Dave

> Dave@Yost.com wrote:
> > Did this get through?  Anyone know what's wrong?
> > Please reply to me directly, as I don't read the list.
> > I tried b10, and the problem is still there.
> 
> I couldn't debug it with `jab' as it was so I changed it so that the
> first one printed called
> jab1() { print 1; }
> and the one in the until called
> jab0() { print 0; }
> and it seemed to work O.K.  If you don't believe this, or can find a
> simpler version of jab that shows the bug, I will try again.

Thanks for your help.  You made me look at it harder.
I made an even more exact simulation that allowed me
to vary some things until I saw what was really happening.

The problem was that the until loop was not being
entered at all.  The ping was succeeding on the first try,
but it took so long that the background message got printed.
For some silly reason, I assumed that this meant the until
loop must have been entered.

In case anyone wants this tool, or wants to
see this interesting shell programming example,
here's the corrected version:

#!/bin/zsh
# or maybe late model ksh

# Force a connection to the Internet over a demand-dial router
# Dave@Yost.com 95-1-28 Works on SGI
# Dave@Yost.com 95-7-18 Fixed the problem with printing the date.

# Parameters for the specific Internet Access Provider
provider=Internex
ppphost=internexppp
provider_support_number="800 291 5178"

verbose=yes
repeating=
tmp=/tmp/internet.$$

case "$1" in
-q) verbose= ;;
-r) repeating=yes ;;
"") ;;
*) echo 1>&2 "
Usage: internet [ -q ]

The -q option suppresses the usual verbose output.
" ;;
esac

jab () {
    ping -qc 1 $ppphost | grep '1 packets received' > /dev/null
    echo $?
}

case "$verbose" in
yes) (sleep  2 ;
      echo "" > $tmp
      echo 1>&2 "Trying to call ${provider}...\c" ;
      sleep 30 ;
      echo 1>&2 ;
      echo 1>&2 "Trouble number is $provider_support_number" ;
      )&
esac

if [[`jab` != 0]] ; then
    until [[`jab` = 0]] ; do
	case "$verbose" in
	yes)
	    echo 1>&2 ".\c"
	esac
    done
fi

case "$verbose" in
yes) kill %%
     if test -r $tmp ; then
	rm -f $tmp
	echo 1>&2 ""
	when=`date`
     else
	when=
     fi
     echo 1>&2 Connected $when
esac


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-07-19  5:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3938.9507181044@pyro.swan.ac.uk>
1995-07-19  4:55 ` commands sometimes don't execute (solved) Dave

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).