home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / getroute.cmd < prev    next >
OS/2 REXX Batch file  |  1998-05-27  |  8KB  |  240 lines

  1. /*---------------------------------------------------------------------------*\
  2. |   Get Lan Server Token Ring Route info      (C) Alain Rykaert - APR98-MAY98 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.03'
  5.     Say '* GETROUTE Version' Version
  6.  
  7.     Call Init                                 /* init dll's and other stuff*/
  8.  
  9.  /*====================================*/
  10.     OutFileName = 'GETROUTE.CSV'                /* Output file with results*/
  11.  /*====================================*/
  12.  
  13.     Say '* Output FileName:' OutFileName
  14.  
  15.     Parse Upper Arg DCName MacAddress
  16.  
  17.     If DCName = '' | MacAddress = ''
  18.       Then Do
  19.              Say '*'
  20.              Say '* Get LAN Server Token Ring Routing Information'
  21.              Say '*'
  22.              Say '* Usage: GETROUTE {DCName} {Destination Address}'
  23.              Say '*'
  24.              Say '* Sample: GETROUTE \\BEDDC01 400013203745'
  25.              Say '*'
  26.              Exit
  27.            End
  28.       Else Nop
  29.  
  30.     DCName = Strip(DCName,'L','\')
  31.     Say '* Server Name:' '\\'DCName
  32.  
  33.     Call OS2Ping MacAddress          /* check if reference adapter is found*/
  34.     If MCheck = 1
  35.       Then Nop
  36.       Else Do
  37.              Say '! Destination Address' MacAddress 'not found'
  38.              Exit
  39.            End
  40.  
  41.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* get server role*/
  42.     If RC = 0
  43.       Then Do
  44.              ServerRole = ServerModalInfo.Role
  45.              If WordPos('Primary', ServerRole) > 0     /* check server role*/
  46.                Then Nop
  47.                Else Do
  48.                       Say '! This is not a Primary Domain Controller' '07'x
  49.                       Exit
  50.                     End
  51.            End
  52.       Else Say RC
  53.  
  54.     RC = NetGetInfo(340, 'ServerName', '\\'DCName, 'Servers')/* get all servers*/
  55.     If RC = 0
  56.       Then Do
  57.             'if exist' OutFileName 'del' OutFileName
  58.              Call RxStemSort 'ServerName'
  59.              Say '* Total defined servers:' ServerName.0
  60.              Do i = 1 to ServerName.0
  61.                Counter = '('Right(i,Length(ServerName.0))'/'Right(ServerName.0,Length(ServerName.0))')'
  62.                Call Logit Copies('-', 60)
  63.                Call Logit '* ServerName:' Counter ServerName.i
  64.                If NetGetInfo(370, 'ServerModalInfo', '\\'ServerName.i) = 0
  65.                  Then Do
  66.                         Call GetInfo ServerName.i
  67.                      /* Call SysSleep 2 */
  68.                       End
  69.                  Else Say '> Not found'
  70.              End
  71.              Call Logit Copies('-', 60)
  72.            End
  73.       Else Say '! Error' RC
  74.  
  75.     Exit
  76.  
  77.  GETINFO:/* -----------------------------------------------------------------*/
  78. trace all
  79.     Parse Arg ServerName
  80.  
  81.    'net admin \\'ServerName '/c set >' TempFile
  82.     Call Stream  TempFile, 'C', 'Close'
  83.  
  84.     Call SysFileSearch 'COMSPEC=', TempFile, 'Stem'
  85.     If Stem.0 = 1
  86.       Then Parse Value Stem.1 With . '=' ServerBootDrive ':' .
  87.       Else Do
  88.              Say '! Error: COMPSPEC not found' '07'x
  89.              Return
  90.            End
  91.  
  92.     IniFileName = '\\'ServerName'\'ServerBootDrive'$\ibmcom\protocol.ini'
  93.     If Trace Then Say IniFileName
  94.  
  95.     If Stream( IniFileName, 'C', 'Query Exists') <> ''
  96.       Then Do
  97.              l = 0
  98.              s = 0
  99.              Do While Lines(IniFileName)
  100.                LLine = LineIn(IniFileName)
  101.                If LLine = ''
  102.                  Then Nop
  103.                  Else Do
  104.                         l = l + 1
  105.                         LLine = Translate(LLine)
  106.                         If Left(Strip(LLine),1) = '['
  107.                           Then Do
  108.                                  s = s + 1
  109.                                  Section.s = LLine          /* section name*/
  110.                                  Section.s.0 = l
  111.                                  l = 0
  112.                                End
  113.                           Else Nop
  114.                         LLine.s.l = Strip(LLine)    /* lines into a section*/
  115.                      /* Say s l LLine.s.l */
  116.                         Section.0 = s
  117.                         LLine.s.0 = l
  118.                       End
  119.              End
  120.              Say Section.0
  121.           /* Do x = 1 to Section.0
  122.                Parse Value Section.x With '[' NicName '_' .
  123.                If NicName = 'IBMTOK'   |,
  124.                   NicName = 'IBMMPC'   |,
  125.                   NicName = 'IBMTRPO2' |,
  126.                   NicName = 'IBMTRBM'  |,
  127.                   NicName = 'IBMTRDB'  |,
  128.                   NicName = 'IBM16OS2'
  129.                  Then Do y = 1 to LLine.x.0
  130.                         Parse Value LLine.x.y With Begin '= "' Address '"' .
  131.                         If Begin = 'NETADDRESS'
  132.                           Then Do
  133.                                  Route = ''
  134.                             /*  'os2ping /a='Address '/w=1 /r >' TempFile '2>nul'
  135.                                  Call SysFileSearch '->', TempFile, 'Stem'
  136.                                  If Stem.0 > 0
  137.                                    Then Do z = 1 to Stem.0
  138.                                           Route = Stem.z Route
  139.                                         End
  140.                                    Else Nop */
  141.                                  Text = ' ' Left(NicName, 8) '-' Address Route
  142.                                  Call Logit Text
  143.                                End
  144.                           Else Nop
  145.                       End
  146.                  Else Nop
  147.              End */
  148.            End
  149.       Else Say '! Error: file' IniFileName 'not found'
  150. trace off
  151.     Return
  152.  
  153.  INIT:/* --------------------------------------------------------------------*/
  154.  
  155.    '@echo off'
  156.  
  157.     If Value('TREES',,'OS2Environment') = ''           /* Check for Tracing*/
  158.       Then Trace = 0
  159.       Else Trace = 1
  160.  
  161.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  162.  
  163.     If RxFuncQuery('SysLoadFuncs')
  164.       Then Do
  165.              Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
  166.              Call SysLoadFuncs
  167.            End
  168.       Else Nop
  169.  
  170.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  171.     PPath = Translate(Value('PATH',,'OS2Environment'))
  172.     x = Pos('\IBMLAN\NETPROG;', PPath) -2
  173.     If x > 0
  174.       Then LSRDrive = SubStr(PPath, x, 2)
  175.       Else Do
  176.              Say '* Could not determine the Lan Requester path'
  177.              Exit
  178.            End
  179.  
  180.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  181.     If RxFuncQuery('LoadLSRXUTFuncs')
  182.       Then Do
  183.              Call RxFuncAdd LoadLsRxutFuncs, LSRXUT, LoadLsRxutFuncs
  184.              Call LoadLsRxutFuncs
  185.            End
  186.       Else Nop
  187.  
  188.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  189.     If RxFuncQuery('RxLoadFuncs')
  190.       Then Do
  191.              Call RxFuncAdd RxLoadFuncs, RXUTILS, RxLoadFuncs
  192.              Call RxLoadFuncs
  193.            End
  194.       Else Nop
  195.  
  196.     TempFile = LSRDrive'\ibmlan\getroute.tmp'             /* Temporary file*/
  197.  
  198.     Return
  199.  
  200.  CHKFILE:/* -----------------------------------------------------------------*/
  201.  
  202.     Parse Arg File_To_Check
  203.  
  204.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  205.       Then Do
  206.              Say '! File not found:' File_To_Check
  207.              Exit
  208.            End
  209.       Else Nop
  210.  
  211.     Return
  212.  
  213.  LOGIT:/* ------------------------------------------------------------------*/
  214.  
  215.     Parse Arg Log_Text
  216.  
  217.     Say OutFileName Log_Text
  218.  Return
  219.     If LineOut(OutFileName, Log_Text) = 0
  220.       Then Call Stream OutFileName, 'C', 'Close'
  221.       Else Say '! Error while writing' OutFileName '07'x
  222.  
  223.     Return
  224.  
  225.  OS2PING:/* ----------------------------------------------------------------*/
  226.  
  227.     Parse Arg Address
  228.  
  229.    '@os2ping /a='Address '/r /w=1 2>nul | Find "(" >' TempFile
  230.     If RC = 0                          /* MAC not found                    */
  231.       Then Do
  232.              MCheck = 0
  233.              Route = LineIn(TempFile)
  234.              Call Stream TempFile, 'C', 'Close'
  235.            End
  236.       Else MCheck = 1
  237.  
  238.     Return
  239.  
  240.