Saturday, March 27, 2010

Correct time

The wireless router does not allow NTP access to the ntp server. Other method need to be used to sync time. One thing I am going to use is the navy.mil timer. The following python code will set the system time to the time from navy.


#!/usr/bin/python
import urllib2, os
Time_Url="http://tycho.usno.navy.mil/cgi-bin/timer.pl"
fp = urllib2.urlopen(Time_Url)
data = fp.read().split()
Month=data[34][4:7]
Day=data[35][0:2]
Time=data[36]
Set_Date= Day+ " "+ Month+" 2010 "+ Time
print Set_Date
os.execlp("/bin/date", "date", "-s", Set_Date)
fp.close()

No comments:

Post a Comment