![]() |
SNTP
Hello All,
Is there any way to pull the date via SNTP from a timeserver with ASP / VBscript? Thank you, Alex |
Re: SNTP
You could try this. I think you may run into permissions issues though that
go along with the same issues you'd find when trying to access a network share. http://www.aspfaq.com/show.asp?id=2168 Response.Write "\\server SNTP server is" & GetSNTPServerSetting("\\server") & "<br>" Response.Write "\\server's time is" & GetTime("\\server") Function GetSNTPServerSetting(hostName) Dim sCommand, oShell, oExec sCommand = "%comspec% /c @echo off & for /f ""tokens=6"" %a in ('net time " & hostName & " /querysntp') do echo %a" Set oShell = CreateObject("WScript.Shell") Set oExec = oShell.Exec(sCommand) GetSNTPServerSetting = oExec.StdOut.ReadAll Set oExec = Nothing Set oShell = Nothing End Function Function GetTime(hostName) Dim sCommand, oShell, oExec sCommand = "%comspec% /c @echo off & for /f ""tokens=6-8"" %a in ('net time " & hostName & "') do echo %a %b %c" Set oShell = CreateObject("WScript.Shell") Set oExec = oShell.Exec(sCommand) GetTime = oExec.StdOut.ReadAll Set oExec = Nothing Set oShell = Nothing End Function Ray at work "AlexM" <me@here.com> wrote in message news:edE4lWfhEHA.3320@TK2MSFTNGP11.phx.gbl... > Hello All, > > Is there any way to pull the date via SNTP from a timeserver with ASP / > VBscript? > > Thank you, > Alex > |
Re: SNTP
I would rather configure the server so that it is synchronized with a source
(either external or an internal one that is itself synchronized), you'll have then just to get the current date/time on this server. If for some reason you want to query a remote server each time, you could use the "net time" command (using WScript.Shell). You may found also the win32 api function at msdn.microsoft.com in which case you could create a wrapper for use from VBScript. Is avoiding solution 1 a requirement ? Patrice -- "AlexM" <me@here.com> a écrit dans le message de news:edE4lWfhEHA.3320@TK2MSFTNGP11.phx.gbl... > Hello All, > > Is there any way to pull the date via SNTP from a timeserver with ASP / > VBscript? > > Thank you, > Alex > |
Re: SNTP
Thanks Ray,
You were right about the permissions. And I don't think I can get my supervisor to loosen his settings. I've never used WScipt before; it looks powerful. (if available) AlexM |
Re: SNTP
Hello Patrice,
To explain what I'm trying to do... I made a routine (ASP/VBScript) to autodelete items from a bulletin board based on an expiration date. For a safety net I'd like the routine to get a 'second opinion' about the date and compare that with the system date before automatically deleting things. I'm just too paranoid to trust the local date to never be wrong. Again I don't want to synchronize the system clock (that task is the sever administrators), I just want to make darn sure it's right via an ASP file. Thank you, AlexM |
Re: SNTP
Is your IIS server a member of a 2000 or 2003 domain? If so, I believe that
all times will be synched with the DC in a default setup. So, you kinda have a built-in second opinion in a way. It's actually only one opinion, but that opinion comes from the DC! :] Ray at work "AlexM" <me@here.com> wrote in message news:e54yR6ghEHA.3076@tk2msftngp13.phx.gbl... > Hello Patrice, > > To explain what I'm trying to do... > > I made a routine (ASP/VBScript) to autodelete items from a bulletin board > based on an expiration date. For a safety net I'd like the routine to get > a > 'second opinion' about the date and compare that with the system date > before > automatically deleting things. I'm just too paranoid to trust the local > date > to never be wrong. Again I don't want to synchronize the system clock > (that > task is the sever administrators), I just want to make darn sure it's > right > via an ASP file. > > Thank you, > AlexM |
Re: SNTP
Greetings again Ray,
It is set up to be all by itself (so it's not allowed to play with the other kids). The server guys keep it locked down pretty tight (rightfully so). I was hoping there was a simple way to use SNTP to double-check the Date from within my script. It does not seem as easy as I hoped. I tried to search about this; but results where cluttered with full blown time sync applications, not a way to 'script' talk to the time server raw. Thought I'd better consult the experts (ie you). So I may have to go to Plan B. I suppose I could hide the expired bulletins for a few days before actually deleting them. That will give me a chance to catch on if something ever goes wrong. (But I really liked Plan A.) It's just that the same contributors clambering for their old bulletins to magically disappear so they don't have to keep track and clean up, will be the same ones to string me up if this auto-cleanup ever goes wrong. Hence my desire to have a safety net. Thank you so much for your efforts, AlexM ************************ Is your IIS server a member of a 2000 or 2003 domain? If so, I believe that all times will be synched with the DC in a default setup. So, you kinda have a built-in second opinion in a way. It's actually only one opinion, but that opinion comes from the DC! :] Ray at work "AlexM" <me@here.com> wrote in message news:e54yR6ghEHA.3076@tk2msftngp13.phx.gbl... > Hello Patrice, > > To explain what I'm trying to do... > > I made a routine (ASP/VBScript) to autodelete items from a bulletin board > based on an expiration date. For a safety net I'd like the routine to get > a > 'second opinion' about the date and compare that with the system date > before > automatically deleting things. I'm just too paranoid to trust the local > date > to never be wrong. Again I don't want to synchronize the system clock > (that > task is the sever administrators), I just want to make darn sure it's > right > via an ASP file. > > Thank you, > AlexM |
Re: SNTP
IMO this is really overkill. I can understand there could be a slight
difference regarding hours but even with a non synchronized server, if you can't even rely on the date there is really a problem (backup date and so on would be nightmare) ! IMO just have a talk with your network guys. Moreover and as you said you coul just use this date as a selection criteria rather than physically destroying records... Patrice -- "AlexM" <me@here.com> a écrit dans le message de news:e54yR6ghEHA.3076@tk2msftngp13.phx.gbl... > Hello Patrice, > > To explain what I'm trying to do... > > I made a routine (ASP/VBScript) to autodelete items from a bulletin board > based on an expiration date. For a safety net I'd like the routine to get a > 'second opinion' about the date and compare that with the system date before > automatically deleting things. I'm just too paranoid to trust the local date > to never be wrong. Again I don't want to synchronize the system clock (that > task is the sever administrators), I just want to make darn sure it's right > via an ASP file. > > Thank you, > AlexM |
| All times are GMT. The time now is 02:50 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.