Re: Local clock question with dialup connection



On 2007-04-23, Nigel Henry <cave.dnb@xxxxxxxxxx> wrote:

The script needs to ping some server on the Internet. If it receives no
response, and exits with a code 1, it will then sleep for 60 secs, then run
the ping again, and so on. When an Internet connection is eventually
established, and that is if I understand this correctly, ping will then exit
with a code 0.

Once a code 0 is received, showing the host to be alive, no further pings
should be sent, and the script at /usr/local/bin/ntp-restart will be run.

Here's one way to do this. Handling situations such as when this script
does not exit or more than one copy of this script is started are left
as an excercise...

#!/bin/sh

# The hostname or IP address of the host that you want to ping.
TARGET=

while [ 1 ]
do
/bin/ping -c 4 $TARGET 2>/dev/null >/dev/null && break
/bin/sleep 60
done

/usr/local/bin/ntp-restart

--
Steve Kostecke <kostecke@xxxxxxxxxxx>
NTP Public Services Project - http://ntp.isc.org/
.



Relevant Pages

  • Re: Help with Expect
    ... > I need some help with an expect script I'm trying to write. ... If the host responds to pings telnet into it. ... You can ping a host and test whether it was successful from a shell ...
    (freebsd-questions)
  • Re: find local computers
    ... >>ping cannot resolve a name, it can resolve a name to IP prior to sending ... > have a way to find all those boxes, ip addr and host name. ... > This script could actually be used to put together canonical hosts files, ... I beleive you need a reverse DNS lookup ...
    (RedHat)
  • Re: Help with Expect Script
    ... I want the script to ping the ... > host to see if it's alive first before it telnets into it. ... I already know how to telnet to the host, ...
    (freebsd-questions)
  • Help with Expect Script
    ... I want the script to ping the ... host to see if it's alive first before it telnets into it. ... I already know how to telnet to the host, ...
    (freebsd-questions)
  • Re: Local clock question with dialup connection
    ... On Monday 23 April 2007 22:20, Steve Kostecke wrote: ... run the ping again, and so on. ... exit with a code 0. ... Handling situations such as when this script ...
    (comp.protocols.time.ntp)