MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Getting the Date and Time From a Time Server

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120959] Re: Getting the Date and Time From a Time Server
  • From: "McHale, Paul" <Paul.McHale at excelitas.com>
  • Date: Fri, 19 Aug 2011 06:33:17 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j25kro$ou6$1@smc.vnet.net> <201108150020.UAA07515@smc.vnet.net>

>> Run["ntpdate -q time.chu.nrc.ca >/tmp/toto"]

An alternative to this approach that I have had come luck with is:

ReadList["!ntpdate -q time.chu.nrc.ca", Record]

This returns a string that is the sum of the program output.  It is analogous to a pipe back into a Mathematica String.  You may need to specify a path.  The nice part is the lack of a generated file.


Paul McHale  |  Electrical Engineer, Energetics Systems  |  Excelitas Technologies Corp.

Phone:   +1 937.865.3004   |   Fax:  +1 937.865.5170   |   Mobile:   +1 937.371.2828
1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
Paul.McHale at Excelitas.com
www.excelitas.com



Please consider the environment before printing this e-mail.
This email message and any attachments are confidential and proprietary to Excelitas Technologies Corp. If you are not the intended recipient of this message, please inform the sender by replying to this email or sending a message to the sender and destroy the message and any attachments.
Thank you

-----Original Message-----
From: S=E9bastien Roy [mailto:roys3d at gmail.com]
Sent: Sunday, August 14, 2011 8:20 PM
To: mathgroup at smc.vnet.net
Subject: [mg120959] Re: Getting the Date and Time From a Time Server

Maybe you could run the "ntpdate" program external and retreive the
time offset between your computer clock and the time server.
(in the following example, the time server is only good in canada)

Run["ntpdate -q time.chu.nrc.ca >/tmp/toto"]
res=Import["/tmp/toto", "Table","FieldSeparators" -> {" ", ","}]
offset=res[[1,6]]   (* not very portable... :-( *)

Now you can use the internal Mathematica clock and add the offset to
get the correct time.

DateList[AbsoluteTime[]+offset]






  • Prev by Date: Memory when reding in data
  • Next by Date: Speeding Up Known Integrations
  • Previous by thread: Re: Getting the Date and Time From a Time Server
  • Next by thread: more efficient method of importing and plotting large (> 100mb) files.