3 die "perl5 needed\n" unless ($] > 5);
7 $opt_f = 0; # 'Hard' failure if 'state' is unknown
8 $opt_n = 1000; # How many tries before we give up? (10 min+)
9 $opt_s = 6; # Seconds to sleep between tries (6s = 10/min)
10 $opt_v = 0; # Be verbose?
14 $cmd = 'ntpq -c "rv 0 state"';
16 $| = 1; # Autoflush output.
18 print "Waiting for ntpd to synchronize... " if ($opt_v);
19 for ($i = 0; $i < $opt_n; ++$i) {
20 open(Q, $cmd." 2>&1 |") || die "Can't start ntpq: $!";
23 print "\bOK!\n" if ($opt_v);
27 if (/request variable was unknown/) {
28 print "\bCan't tell!\nPerhaps you are running an old version of ntpd.\n" if ($opt_v);
32 if (/Connection refused/) {
33 print "\bntpd is not running!\n" if ($opt_v);
38 print "\b".substr("*+:.", $i % 4, 1) if ($opt_v);
41 print "\bNo!\nntpd did not synchronize.\n" if ($opt_v);