On Thu, 27 Jan 2000, Dale W Hodge wrote:

>> #!/bin/sh
>> if ( /sbin/ifconfig | grep -q ppp0 ); then
>> echo "Connected on line."
>> else
>> echo "On line not connected."
>> fi

> While this works in *most* situations, it does not work in *all*
> situations.

Yes, that's the problem with most of the suggestions so far. 
Here's a fragment of a quick hack that I use to examine the state
of the link, which should work in all situations.  It's a bit slow
because the diald-monitor info only comes once every second, and
because of the sleep/wait construction, for which there must be a
better way.  However, it's correct and fairly simple. 

By the way, why would anyone want to know the status of the link?
The whole point of diald is to bring the link up and down
transparently.

#!/bin/sh

##### routine to determine link status from diald-monitor

# This is a bad five-minute hack.  Use at your own risk.

# change these as you see fit; DDMONITOR should go somewhere else
DIALDFIFO=/var/run/diald/diald.fifo
DDMONITOR=/root/diald.monitor

# This ugly construction sleep ... & ... wait is used because
# diald stops writing to the pipe when there's nothing to
# read the remote end.  There must be a better way.
(sleep 1 ; echo monitor ${DDMONITOR} > ${DIALDFIFO}) &
if cat ${DDMONITOR} | ( grep -q STATUS ; head -n 2 ) | grep 0; then
  DDSTATUS="DOWN";
else
  DDSTATUS="UP";
fi
wait

##### end of routine


##### Now use the status info however we wish

echo $DDSTATUS





-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]

Reply via email to