home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / nist2.zip / nist2.cmd
OS/2 REXX Batch file  |  1995-08-26  |  3KB  |  86 lines

  1. /* REXX */
  2. /* Procedure to call Boulder NIST and set System Time  */
  3. /* With acknowledgement to Jerry am Ende, Compuserve 73237,131            */
  4. /* Defaults are peculiar to my system. Change them to suit yours.        */        
  5. /* Thomas M Maddox (maddtom@ibm.net) Boulder CO Somewhere between the Mtns and reality. */
  6. /* 26Aug1995                                    */
  7. parse arg year offset PhoneNumber ComPort
  8.  
  9. "CLS"                                           /* Clear Screen */
  10.  
  11. /*if year = "" then do                              */
  12. /*   say "Usage is: TIMESET <year> <offset> <PhoneNumber> <ComPort>"        */
  13. /*   say "          <year>        = 2 digit year (e.g. 1992 = 92)"        */
  14. /*   say "          <offset>      = Hours from Greenwich Mean time. "        */
  15. /*   say "                           Mountain = 6 "                   */
  16. /*   say "          <PhoneNumber> = Phone Number of NIST"            */
  17. /*   say "                           default is  NIST 494-4774 or 494-4775"    */
  18. /*   say "          <ComPort>     = ComPort where modem is connected"        */
  19. /*   say "                           COM2 is default                */
  20. /*   return                                    */
  21. /*   end                                      */
  22. if year == "" then
  23.     year = 95
  24. if offset == "" then                                /* Set Defaults */
  25.    offset = 6
  26.  
  27. if PhoneNumber == "" then
  28.    PhoneNumber = "4944774"
  29.  
  30. if ComPort == "" then
  31.    ComPort = "COM2"
  32.  
  33. CrLf = X2C("0D0A")
  34.  
  35. State = STREAM(ComPort,"C","OPEN")
  36. "@MODE" ComPort":115200,N,8,1 > NUL"
  37.  
  38. CALL LINEOUT ComPort, "ATX3DT"PhoneNumber||CrLf                 /* Dial In */
  39. StartTime = time('E')
  40. ReturnStuff = ""
  41. DO WHILE pos('UTC',ReturnStuff) == 0                   /* UTC is end of String */
  42.   ReturnStuff = ReturnStuff||CHARIN(ComPort)
  43.   if (pos('BUSY',ReturnStuff) <> 0) then do                  /* Check for Busy */
  44.      CALL LINEOUT ComPort,"ATH"CrLf                                   /* Hang Up */
  45.      State = STREAM(ComPort,"C","CLOSE")
  46.      Say "Line Busy, Please Try Again..."
  47.      return
  48.      end
  49.   if ((time('E') - StartTime) > 45) then do                           /* Check for Timeout */
  50.      CALL LINEOUT ComPort,"ATH"CrLf                                             /* Hang Up */
  51.      State = STREAM(ComPort,"C","CLOSE")
  52.      Say "Sorry, Timeout..."
  53.      return
  54.      end
  55. END
  56.  
  57. NISTString = Right(ReturnStuff,36)                  /* Retrieve the time/date string */
  58.  
  59. parse var NISTString  doy time . . . .
  60.                                 /* Convert time to HH:MM:SS */
  61. hour = right(left(time,2) - offset,2,'0')
  62. if (hour < 0) then do
  63.    hour = hour + 24
  64.    doy = doy - 1
  65.    end
  66. minute = right(substr(time,4,2),2,'0')
  67. second = right(substr(time,7,2),2,'0')
  68. TimeString = hour || ':' || minute || ':' || second
  69.  
  70.                               /* Convert doy to MM-DD-YY format */
  71. month = right(substr(doy,4,2),2,'0')
  72. day = right(substr(doy,7,2),2,'0')
  73. DateString = month || '-' || day || '-' || Year
  74.  
  75. OldTime = Time()
  76. OldDate = Date()
  77.  
  78.                                 /* Send Date & Time to OS2 */
  79. "@DATE" DateString        
  80. "@TIME" TimeString
  81.         
  82. Say "Date & Time was            .... " OldDate OLdTime
  83. Say "Date & Time has been Set to:" Date() Time()
  84.  
  85. return
  86.