Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Windows Time in Perl

Status
Not open for further replies.

thebarslider

Programmer
Dec 21, 2001
80
GB
Hello All,

I have a bit of a problem, i need to work out the date/time from a Perl script running on a local Windows box. But i need to retrieve the time from a Windows server to ensure it is accurate, does anyone have any ideas on how to do this?

All suggestions are much appreciated.

Mark.
 
Have I got this right?

Windows Time on the Client
Windows Time on the Server
Compare

If so, you'll need some sort of service to get the time back from the server, so it's running under the server resources, as opposed to just running a file that resides on the server

You could use SRVANY to install a perl script as a service, which simply updates a file with the time each second, if thats granular enough, and have the local script read form that file

Or it could issue a request on a socket, and return the time of the server.

If it was me, i'd have all the windows machines taking their time from the same source, from an administration point of view

HTH
--Paul

cigless ...
 
Net::NTP seems to do what you want, you can get the module from and there's (poor) documentation at
To do this the server you want to check will have to be running an ntp time server.

You'll also have to have a look at RFC1305 which is available at as Net::NTP returns values in the format defined in RFC1305.

The Net::NTP "documentation" says that it "returns an associative array of the various parts of the packet as outlined in RFC1305" which isn't very helpful really, you'll have to dig through the contents of what it returns.

Mike

You cannot really appreciate Dilbert unless you've read it in the
original Klingon.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top