home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lstime.cmd < prev    next >
OS/2 REXX Batch file  |  2000-01-07  |  5KB  |  153 lines

  1. /*---------------------------------------------------------------------------*\
  2. |   Check LAN Server Time                                (C) AR - DEC99-JAN00 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.03 (C) AR - JAN2000'
  5.     Say '* LSTIME Version' Version
  6.  
  7.     Signal On Halt Name Quit
  8.     Call Init                                 /* Init DLL's and other stuff*/
  9.  
  10.     Parse Upper Arg DCName MaxTime
  11.  
  12.     If DCName = ''
  13.       Then Do
  14.              Say '*'
  15.              Say '* Check all Time clocks'
  16.              Say '*'
  17.              Say '* Usage: LSTIME {DCName} {MaxTime}'
  18.              Say '*'
  19.              Say '* Sample: LSTIME \\DC01 60'
  20.              Say '*'
  21.              Exit
  22.            End
  23.       Else Nop
  24.  
  25.     DCName = Strip(DCName,'L','\')
  26.     Say '* Server Name:' '\\'DCName
  27.  
  28.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* Get server role*/
  29.     If RC = 0 & Stream('\\'DCName'\ibmlan$\ibmlan.ini', 'C', 'Query Exists') <> ''
  30.       Then Do
  31.              ServerRole = ServerModalInfo.Role
  32.              If WordPos('Primary', ServerRole) > 0
  33.                Then Nop
  34.                Else Do
  35.                       Say '! This is not a Primary Domain Controller' '07'x
  36.                       Exit
  37.                     End
  38.            End
  39.       Else Do
  40.              Say '! Error:' RC
  41.              Exit
  42.            End
  43.  
  44.     If MaxTime < 0 | MaxTime > 9999
  45.       Then Do
  46.              Say '* Scanning with the default MaxTime of 60'
  47.              MaxTime = 60
  48.            End
  49.       Else Nop
  50.  
  51.     RC = NetGetInfo(340, 'ServerName', '\\'DCName, 'Servers')/* get servers*/
  52.     If RC = 0
  53.       Then Do
  54.              Call RxStemSort 'ServerName'
  55.              Say '* Total defined servers:' ServerName.0
  56.              Do i = 1 to ServerName.0
  57.                Counter = '('Right(i,Length(ServerName.0))'/'Right(ServerName.0,Length(ServerName.0))')'
  58.                Call Charout ,'* ServerName:' Counter Left(ServerName.i,9)
  59.                RC = NetMisc(700, 'SrvTime', '\\'ServerName.i)
  60.                If RC = 0
  61.                  Then Do
  62.                         ActTime = SrvTime.Tod_Year               || '-' ||,
  63.                                   Right(SrvTime.Tod_Month,2,'0') || '-' ||,
  64.                                   Right(SrvTime.Tod_Day,2,'0'),
  65.                                   SrvTime.Tod_Hours || ':' ||,
  66.                                   Right(SrvTime.Tod_Mins,2,'0') || ':' ||,
  67.                                   Right(SrvTime.Tod_Secs,2,'0')
  68.  
  69.                         Call NetMisc 700, 'PdcTime', '\\'DCName/* Time on PDC*/
  70.  
  71.                         DeltaTime = ABS(PdcTime.Tod_ElapsedT-SrvTime.Tod_ElapsedT)
  72.                         If ABS(DeltaTime) > MaxTime
  73.                           Then Say ':' ActTime '-' Right(DeltaTime,3,' '),
  74.                                    '<--- Attention ---'
  75.                           Else Say ':' ActTime '-' Right(DeltaTime,3,' ')
  76.                       End
  77.                  Else Say '> not found'
  78.              End
  79.            End
  80.       Else Say RC
  81.  
  82.     Exit
  83.  
  84.  INIT:/* --------------------------------------------------------------------*/
  85.  
  86.    '@echo off'
  87.  
  88.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  89.  
  90.     If RxFuncQuery('SysLoadFuncs')
  91.       Then Do
  92.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  93.              Call SysLoadFuncs
  94.            End
  95.       Else Nop
  96.  
  97.     LSRDrive = Left(SysSearchPath('PATH', 'NET.EXE'), 2)    /* IBMLAN Drive*/
  98.     If LSRDrive <> ''
  99.       Then Nop
  100.       Else Do
  101.              Say '! Could not determine the Lan Requester path' '07'x
  102.              Exit X2D('1604')
  103.            End
  104.  
  105.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  106.     If RxFuncQuery('LoadLSRxutFuncs')
  107.       Then Do
  108.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  109.              Call LoadLsRxutFuncs
  110.            End
  111.       Else Nop
  112.  
  113.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  114.     If RxFuncQuery('RxLoadFuncs')
  115.       Then Do
  116.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  117.              Call RxLoadFuncs
  118.            End
  119.       Else Nop
  120.  
  121.     Return
  122.  
  123.  CHKFILE:/* -----------------------------------------------------------------*/
  124.  
  125.     Parse Arg File_To_Check
  126.  
  127.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  128.       Then Do
  129.              Say '! File not found:' File_To_Check
  130.              Exit
  131.            End
  132.       Else Nop
  133.  
  134.     Return
  135.  
  136.  LOGIT:/* -------------------------------------------------------------------*/
  137.  
  138.     Parse Arg OutFileName OutText
  139.  
  140.     If LineOut(OutFileName, OutText) = 0
  141.       Then Call Stream OutFileName, 'C', 'Close'
  142.       Else Say '! Error while writing:' OutFileName '07'x
  143.  
  144.     Return
  145.  
  146.  QUIT:/* --------------------------------------------------------------------*/
  147.  
  148.     Say
  149.     Say '...Interupted by User...'
  150.  
  151.     Exit X2D('1604')
  152.  
  153.