SNTP

Discussion in 'ASP General' started by AlexM, Aug 19, 2004.

  1. AlexM

    AlexM Guest

    Hello All,

    Is there any way to pull the date via SNTP from a timeserver with ASP /
    VBscript?

    Thank you,
    Alex
    AlexM, Aug 19, 2004
    #1
    1. Advertising

  2. AlexM

    Ray at Guest

    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" <> wrote in message
    news:...
    > Hello All,
    >
    > Is there any way to pull the date via SNTP from a timeserver with ASP /
    > VBscript?
    >
    > Thank you,
    > Alex
    >
    Ray at, Aug 19, 2004
    #2
    1. Advertising

  3. AlexM

    Patrice Guest

    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" <> a écrit dans le message de
    news:...
    > Hello All,
    >
    > Is there any way to pull the date via SNTP from a timeserver with ASP /
    > VBscript?
    >
    > Thank you,
    > Alex
    >
    Patrice, Aug 19, 2004
    #3
  4. AlexM

    AlexM Guest

    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
    AlexM, Aug 19, 2004
    #4
  5. AlexM

    AlexM Guest

    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
    AlexM, Aug 19, 2004
    #5
  6. AlexM

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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
    Ray at, Aug 19, 2004
    #6
  7. AlexM

    AlexM Guest

    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" <> wrote in message
    news:...
    > 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
    AlexM, Aug 19, 2004
    #7
  8. AlexM

    Patrice Guest

    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" <> a écrit dans le message de
    news:...
    > 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
    Patrice, Aug 20, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jed
    Replies:
    0
    Views:
    421
  2. Rahmi Acar
    Replies:
    0
    Views:
    374
    Rahmi Acar
    Jul 9, 2003
  3. Allen
    Replies:
    4
    Views:
    2,879
    Allen
    Aug 31, 2006
Loading...

Share This Page