Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4466

Re: Getting the Date and Time From a Time Server

From "McHale, Paul" <Paul.McHale@excelitas.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Getting the Date and Time From a Time Server
Date 2011-08-19 10:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j2le91$nf0$1@smc.vnet.net> (permalink)
References <j25kro$ou6$1@smc.vnet.net> <201108150020.UAA07515@smc.vnet.net>

Show all headers | View raw


>> 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@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@gmail.com]
Sent: Sunday, August 14, 2011 8:20 PM
Subject: 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]


Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Getting the Date and Time From a Time Server Gregory Lypny <gregory.lypny@videotron.ca> - 2011-08-13 10:49 +0000
  Re: Getting the Date and Time From a Time Server Sébastien Roy <roys3d@gmail.com> - 2011-08-15 00:24 +0000
  Re: Getting the Date and Time From a Time Server "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-08-19 10:35 +0000

csiph-web