home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lsconfig.cmd < prev    next >
OS/2 REXX Batch file  |  2001-05-01  |  12KB  |  356 lines

  1. /*---------------------------------------------------------------------------*\
  2. |   Get Configuration from all servers        (C) Alain Rykaert - AUG98-APR00 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.07b (C) AR - DEC2000'
  5.     Say '* LSCONFIG Version' Version
  6.  
  7.     Call Init                                 /* init dll's and other stuff*/
  8.  
  9.    'if not exist' LSRDrive'\ibmlan\tmp md' LSRDrive'\ibmlan\tmp'
  10.     TempFile = LSRDrive'\ibmlan\tmp\lsconfig.tmp'         /* Temporary file*/
  11.  
  12.     Parse Upper Arg DCName OutFileName
  13.  
  14.     If DCName = '' | OutFileName = ''
  15.       Then Do
  16.              Say '*'
  17.              Say '* Get LAN Server Config'
  18.              Say '*'
  19.              Say '* Usage: LSCONFIG {DCName} {OutputFileName}'
  20.              Say '*'
  21.              Say '* Sample: LSCONFIG \\DC01 LSCONFIG.CSV'
  22.              Say '*'
  23.              Exit X2D('1600')
  24.            End
  25.       Else Nop
  26.  
  27.     DCName = Strip(DCName,'L','\')
  28.     Say '* Server Name:' '\\'DCName
  29.     Say '* Output FileName:' OutFileName
  30.  
  31.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* get server role*/
  32.     If RC = 0
  33.       Then Do
  34.              ServerRole = ServerModalInfo.Role
  35.              If WordPos('Primary', ServerRole) > 0     /* check server role*/
  36.                Then Nop
  37.                Else Do
  38.                       Say '! This is not a Primary Domain Controller' '07'x
  39.                       Exit X2D('1600')
  40.                     End
  41.            End
  42.       Else Say RC
  43.  
  44.     RC = NetGetInfo(340, 'ServerName', '\\'DCName, 'Servers')/* get all servers*/
  45.     If RC = 0
  46.       Then Do
  47.             'if exist' OutFileName 'del' OutFileName
  48.              OutText = '***' Date() Time() '*** LSCONFIG Version:' Version
  49.              Call Logit OutFileName OutText
  50.              Call Logit OutFileName ' '
  51.              Call RxStemSort 'ServerName'
  52.              Say '* Total defined servers:' ServerName.0
  53.          /*  Counter = Left('COUNTER', (Length(ServerName.0) * 2)+3) */
  54.  
  55.              Text = Left('SERVER ',8)      ';',
  56.                     Left('IPADDRESS',15)   ';',
  57.                     Left('NETMASK',15)     ';',
  58.                     Left('HOSTNAME',8)     ';',
  59.                     Left('MACADDRESS',12)  ';',
  60.                     Left('XID',8)          ';',
  61.                     Left('DESTINATION',12) ';',
  62.                     Left('ADSMNAME',8)     ';',
  63.                     Left('ADSMSERV',12)    ';',
  64.                     Left('NIC',3)          ';',
  65.                     Left('NICTYPE',8)      ';'
  66.  
  67.              Call Logit OutFileName Text
  68.  
  69.              Do i = 1 to ServerName.0
  70.                Counter = '('Right(i,Length(ServerName.0))'/'Right(ServerName.0,Length(ServerName.0))')'
  71.                Call CharOut,'* ServerName:' Counter ServerName.i
  72.                Text = Left(ServerName.i,9) || ';'
  73.                If NetGetInfo(370, 'ServerModalInfo', '\\'ServerName.i) = 0
  74.                  Then Do
  75.                         Say
  76.                         Call GetInfo ServerName.i
  77.                       End
  78.                  Else Say ' > not found'
  79.                Call Logit OutFileName Text
  80.              End
  81.            End
  82.       Else Say RC
  83.  
  84.     Exit
  85.  
  86.  GETINFO:/* ----------------------------------------------------------------*/
  87.  
  88.     Parse Arg ServerName
  89.     IPAddress = ''
  90.     NetMask = ''
  91.     HostName = ''
  92.     MACAddress = ''
  93.     NicCount = ''
  94.     XID = ''
  95.     TIC = ''
  96.     AdsmName = ''
  97.     AdsmServ = ''
  98.  
  99.    'net admin \\'ServerName '/c set >' TempFile
  100.     Call Stream TempFile, 'C', 'Close'
  101.     If Stream(TempFile, 'C', 'Query Size') > 0
  102.       Then Nop
  103.       Else Do
  104.              Say '! Error: tempfile' TempFile 'is not valid' '07'x
  105.              Return
  106.            End
  107.  
  108.     Call SysFileSearch 'COMSPEC=', TempFile, 'Stem'
  109.     If Stem.0 = 1
  110.       Then Do
  111.              Parse Var Stem.1 . '=' ServerBootDrive ':' .
  112.              If Trace Then Say '> Boot Drive:' ServerBootDrive
  113.              LibPath = ''
  114.              Call SysFileSearch 'LIBPATH=', '\\'ServerName'\'ServerBootDrive'$\config.sys', 'Stem'
  115.              Do j = 1 to Stem.0
  116.                Stem.j = Translate(Stem.j)
  117.                If Left(Strip(Stem.j), 8) = 'LIBPATH='
  118.                  Then Parse Var Stem.j . '=' LibPath
  119.                  Else Nop
  120.              End
  121.              If LibPath = ''
  122.                Then Do
  123.                       Say '! Error: could not determine LibPath' '07'x
  124.                       Return
  125.                     End
  126.                Else If Trace Then Say '> LibPath:' LibPath
  127.            End
  128.       Else Do
  129.              Say '! Error: could not determine ComSpec' '07'x
  130.              Return
  131.            End
  132.  
  133.     DRV_OS2 = ''
  134.     DRV_LSR = ''
  135.     DRV_CM2 = ''
  136.     DRV_MPTS = ''
  137.     DRV_PCOM = ''
  138.  
  139.     Do While LibPath <> ''
  140.       DriveLetter = ''
  141.       Parse Upper Value LibPath With QPath ';' LibPath
  142.       If Pos(':',QPath) > 0
  143.         Then Parse Value QPath With DriveLetter ':' QPath
  144.         Else Nop
  145.       Select
  146.        When QPath = '\IBMLAN\NETLIB'                          /* Lan Server*/
  147.          Then DRV_LSR = '\\'ServerName'\'DriveLetter'$'
  148.        When QPath = '\IBMCOM\DLL'                                   /* MPTS*/
  149.          Then DRV_MPTS = '\\'ServerName'\'DriveLetter'$'
  150.        When QPath = '\TCPIP\DLL'                                  /* TCP/IP*/
  151.          Then DRV_TCP = '\\'ServerName'\'DriveLetter'$'
  152.        When QPath = '\CMLIB\DLL'                                    /* CM/2*/
  153.          Then DRV_CM2 = '\\'ServerName'\'DriveLetter'$'
  154.        When QPath = '\PCOMOS2'                                     /* PCOMM*/
  155.          Then DRV_PCOM = '\\'ServerName'\'DriveLetter'$'
  156.        OtherWise Nop
  157.       End
  158.     End
  159.  /*
  160.     DRV_OS2 = ''
  161.     DRV_LSR = ''
  162.     DRV_CM2 = ''
  163.     DRV_MPTS = ''
  164.     DRV_PCOM = ''
  165.                   */
  166.   /* Get IP */
  167.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\mptn\bin\setup.cmd'
  168.      If Stream(ConfigFile, 'C', 'Query Exists') <> ''
  169.        Then Do
  170.               Call SysFileSearch 'ifconfig lan0', ConfigFile, 'Stem'
  171.               If Stem.0 = 1
  172.                 Then Parse Var Stem.1 . . IPAddress . NetMask .
  173.                 Else Nop
  174.             End
  175.        Else Nop
  176.  
  177.   /* Get HostName */
  178.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\config.sys'
  179.      Call SysFileSearch 'SET HOSTNAME=', ConfigFile, 'Stem'
  180.      If Stem.0 = 1
  181.        Then Parse Var Stem.1 . '=' HostName
  182.        Else Nop
  183.  
  184.   /* Get MAC */
  185.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\ibmcom\protocol.ini'
  186.      Call SysFileSearch 'NetAddress =', ConfigFile, 'Stem'
  187.      If Stem.0 > 0
  188.        Then Do
  189.               Parse Var Stem.1 . '=' MacAddress .
  190.               MacAddress = Strip(MacAddress,,'"')
  191.               MacAddress = Strip(MacAddress,,'T')
  192.             End
  193.        Else Nop
  194.  
  195.   /* Get Number of Network Adapters */
  196.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\config.sys'
  197.      Call SysFileSearch '\macs\', ConfigFile, 'Found'
  198.      If Found.0 > 0
  199.        Then Do n = 1 to Found.0
  200.               If Pos('rem',Found.n) > 0
  201.                 Then Nop
  202.                 Else Do
  203.                        Parse Var Found.n . '\' . '\' . '\' NicType '.' .
  204.                        Look = '['NicType'_NIF'
  205.                        ConfigFile = '\\'ServerName'\'ServerBootDrive'$\ibmcom\protocol.ini'
  206.                        Call SysFileSearch Look, ConfigFile, 'NifFound'
  207.                        If NifFound.0 = 0
  208.                          Then Call SysFileSearch '[IBMTRPO2_NIF', ConfigFile, 'NifFound'
  209.                          Else Nop
  210.                        NicCount = NifFound.0
  211.                      End
  212.             End
  213.        Else NicCount = ''
  214.  
  215.   /* Get CM/2 NDF */
  216.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\cmlib\cm.ini'
  217.      If Stream(ConfigFile, 'C', 'Query Exists') <> ''
  218.        Then Do
  219.               Call SysFileSearch 'CMDefaultCFG=', ConfigFile, 'Stem'
  220.               If Stem.0 = 1
  221.                 Then Do
  222.                        Parse Var Stem.1 . '=' NDF .
  223.                        NDFFile = '\\'ServerName'\'ServerBootDrive'$\cmlib\'NDF'.ndf'
  224.                        Call SysFileSearch 'NODE_ID', NDFFile, 'Found'
  225.                        Parse Var Found.1 . "'" XID "'"
  226.                        Call SysFileSearch 'DESTINATION_ADDRESS', NDFFile, 'Found'
  227.                        Parse Var Found.1 . "'" TIC "'"
  228.                      End
  229.                 Else Nop
  230.             End
  231.        Else Nop
  232.  
  233.   /* Get ADSM Config */
  234.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\adsm\dsm.opt'
  235.      If Stream(ConfigFile, 'C', 'Query Exists') <> ''
  236.        Then Do
  237.               Call SysFileSearch 'NODENAME', ConfigFile, 'Stem'
  238.               If Stem.0 = 1
  239.                 Then Parse Var Stem.1 . AdsmName .
  240.                 Else Nop
  241.               Call SysFileSearch 'TCPSERVERADDRESS', ConfigFile, 'Stem'
  242.               If Stem.0 = 1
  243.                 Then Parse Var Stem.1 . AdsmServ .
  244.                 Else Nop
  245.             End
  246.        Else Nop
  247.  
  248.      ConfigFile = '\\'ServerName'\'ServerBootDrive'$\pgms\adsm\dsm.opt'
  249.      If Stream(ConfigFile, 'C', 'Query Exists') <> ''
  250.        Then Do
  251.               Call SysFileSearch 'NODENAME', ConfigFile, 'Stem'
  252.               If Stem.0 = 1
  253.                 Then Parse Var Stem.1 . AdsmName .
  254.                 Else Nop
  255.               Call SysFileSearch 'TCPSERVERADDRESS', ConfigFile, 'Stem'
  256.               If Stem.0 = 1
  257.                 Then Parse Var Stem.1 . AdsmServ .
  258.                 Else Nop
  259.             End
  260.        Else Nop
  261.  
  262.     AdsmName = Strip(AdsmName)
  263.     AdsmName = Strip(AdsmName,,'09'x)
  264.     AdsmServ = Strip(AdsmServ)
  265.     AdsmServ = Strip(AdsmServ,,'09'x)
  266.  
  267.     Text = Left(ServerName.i,8) ';',
  268.            Left(IPAddress,15)   ';',
  269.            Left(NetMask,15)     ';',
  270.            Left(HostName,8)     ';',
  271.            Left(MacAddress,12)  ';',
  272.            Left(XID,8)          ';',
  273.            Left(TIC,12)         ';',
  274.            Left(AdsmName,8)     ';',
  275.            Left(AdsmServ,12)    ';',
  276.            Center(NicCount,3)   ';',
  277.            Left(NicType,8)      ';'
  278.  
  279.     If Trace Then Say '>' Text
  280.  
  281.    'net use \\'ServerName'\c$ /d >nul 2>nul'
  282.    'net use \\'ServerName'\d$ /d >nul 2>nul'
  283.    'net use \\'ServerName'\ipc$ /d >nul 2>nul'
  284.    'net use \\'ServerName'\ibmlan$ /d >nul 2>nul'
  285.  
  286.     Return
  287.  
  288.  INIT:/* --------------------------------------------------------------------*/
  289.  
  290.    '@echo off'
  291.  
  292.     If Value('TREES',,'OS2Environment') = ''           /* Check for Tracing*/
  293.       Then Trace = 0
  294.       Else Trace = 1
  295.  
  296.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  297.  
  298.     Redir = '>nul'
  299.  
  300.     If RxFuncQuery('SysLoadFuncs')
  301.       Then Do
  302.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  303.              Call SysLoadFuncs
  304.            End
  305.       Else Nop
  306.  
  307.     LSRDrive = Left(SysSearchPath('PATH', 'NET.EXE'), 2)    /* IBMLAN Drive*/
  308.     If LSRDrive <> ''
  309.       Then Nop
  310.       Else Do
  311.              Say '! Could not determine the Lan Requester path' '07'x
  312.              Exit X2D('1604')
  313.            End
  314.  
  315.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  316.     If RxFuncQuery('LoadLSRXUTFuncs')
  317.       Then Do
  318.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  319.              Call LoadLsRxutFuncs
  320.            End
  321.       Else Nop
  322.  
  323.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  324.     If RxFuncQuery('RxLoadFuncs')
  325.       Then Do
  326.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  327.              Call RxLoadFuncs
  328.            End
  329.       Else Nop
  330.  
  331.     Return
  332.  
  333.  CHKFILE:/* -----------------------------------------------------------------*/
  334.  
  335.     Parse Arg File_To_Check
  336.  
  337.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  338.       Then Do
  339.              Say '! File not found:' File_To_Check
  340.              Exit X2D('0800')
  341.            End
  342.       Else Nop
  343.  
  344.     Return
  345.  
  346.  LOGIT:/* -------------------------------------------------------------------*/
  347.  
  348.     Parse Arg OutFileName OutText
  349.  
  350.     If LineOut(OutFileName, OutText) = 0
  351.       Then Call Stream OutFileName, 'C', 'Close'
  352.       Else Say '! Error while writing:' OutFileName '07'x
  353.  
  354.     Return
  355.  
  356.