#!/bin/sh
# File  : rdate
# By    : M. de Boer
# At    : 960226
#
# rdate = a script which gets the date from an other machine
# and set the CMOS date.
# The 4th line is the output from the other host.
#
# Syntax : rdate chime1.surfnet.nl, ntp0.NL.net, ntp1.NL.net, ntp2.NL.net
# Or     : time_a.timefreq.bldrdoc.gov
#
#
#set -x
LOGFILE=/var/log/rdate.log

touch $LOGFILE
l=0
telnet $1 13 > /tmp/rdate.tmp
cat /tmp/rdate.tmp |  while read line
do
  l=`expr $l + 1`
  if [ $l -eq 4 ]
  then
#    echo $line > /tmp/rdate.tmp

    echo -n "`date +%y%m%d' '%H':'%M':'%S` rdate: date set from $1 = " >> $LOGF
LE
    echo -n "`date +%y%m%d' '%H':'%M':'%S` rdate: date set from $1 = "

#    echo "$line" >> $LOGFILE
#    echo "line: $line"

    date --set "$line"
    /sbin/clock -w
  fi
done
#rm -f /tmp/rdate.tmp 


