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

  1. /*---------------------------------------------------------------------------*\
  2. |   Lan Server Browser                        (C) Alain Rykaert - APR95-DEC99 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '2.07a (C) AR - JAN01'
  5.     Say '* LSBROWSE Version' Version
  6.  
  7.     Call Init                                 /* init dll's and other stuff*/
  8.     Signal On Halt Name Quit
  9.  
  10.     Parse Upper Arg DCName OutFileName
  11.  
  12.     If DCName = '' | OutFileName = ''
  13.       Then Do
  14.              Say '*'
  15.              Say '* Browse LAN Server parameters'
  16.              Say '*'
  17.              Say '* Usage: LSBROWSE {DCName} {OutputFileName}'
  18.              Say '*'
  19.              Say '* Sample: LSBROWSE \\BEDDC01 LSBROWSE.CSV'
  20.              Say '*'
  21.              Exit
  22.            End
  23.       Else Nop
  24.  
  25.     DCName = Strip(DCName,'L','\')
  26.     Say '* Server Name:' '\\'DCName
  27.     Say '* Output FileName:' OutFileName
  28.  
  29.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* get server role*/
  30.     If RC = 0
  31.       Then Do
  32.              ServerRole = ServerModalInfo.Role
  33.              If WordPos('Primary', ServerRole) > 0     /* check server role*/
  34.                Then Nop
  35.                Else Do
  36.                       Say '! This is not a Primary Domain Controller' '07'x
  37.                       Exit
  38.                     End
  39.            End
  40.       Else Say RC
  41.  
  42.     RC = NetGetInfo(340, 'ServerName', '\\'DCName, 'Servers')/* get all servers*/
  43.     If RC = 0
  44.       Then Do
  45.             'if exist' OutFileName 'del' OutFileName
  46.              OutText = '***' Date() Time() '*** LSBROWSE Version:' Version
  47.              Call Logit OutFileName OutText
  48.              Call Logit OutFileName ' '
  49.              OutText = "SERVER  "            ';',
  50.                        "TIME "               ';',
  51.                        "ROLE"                ';',
  52.                        "NET.ACC"             ';',
  53.                        "ACTTIME            " ';',
  54.                        "BALANCE"             ';',
  55.                        "CACHE "              ';',
  56.                        "UAM"                 ';',
  57.                        "HEAP "               ';',
  58.                        "NET1  "              ';',
  59.                        "NET2  "              ';',
  60.                        "NET3  "              ';',
  61.                        "NET4  "              ';',
  62.                        "NET5  "              ';',
  63.                        "DISC"                ';',
  64.                        "MAXUSERS"            ';',
  65.                        "MAXCONN"             ';',
  66.                        "MAXSHARES"           ';'
  67.  
  68.              Call Logit OutFileName OutText
  69.  
  70.              Call RxStemSort 'ServerName'
  71.              Say '* Total defined servers:' ServerName.0
  72.              Do i = 1 to ServerName.0
  73.                Counter = '('Right(i,Length(ServerName.0))'/'Right(ServerName.0,Length(ServerName.0))')'
  74.                Call Charout 'con', '* ServerName:' Counter ServerName.i
  75.                OutText = Left(ServerName.i,9) || ';'
  76.                If NetGetInfo(370, 'ServerModalInfo', '\\'ServerName.i) = 0
  77.                  Then Do
  78.                         Call GetInfo ServerName.i
  79.                         Say ''
  80.                       End
  81.                  Else Say '09'x '> not found'
  82.                Call Logit OutFileName OutText
  83.              End
  84.            End
  85.       Else Say RC
  86.  
  87.     Exit
  88.  
  89.  GETINFO:/* ----------------------------------------------------------------*/
  90.  
  91.     Parse Arg ServerName
  92.  
  93.  /* get server role from previous api*/
  94.     ServerRole = Translate(Left(ServerModalInfo.Role,4))
  95.  
  96.     Balance = ''                                  /* Auto balance from MPTS*/
  97.  
  98.     Call Time('R')                                       /* Reset the timer*/
  99.  
  100.    'net admin \\'ServerName '/c set >' TempFile
  101.     Call Stream TempFile, 'C', 'Close'
  102.  
  103.     Call SysFileSearch 'COMSPEC=', TempFile, 'Stem'
  104.     If Stem.0 = 1
  105.       Then Do
  106.              Parse Value Stem.1 With . '=' ServerBootDrive ':' .
  107.              If Trace Then Say '> Boot Drive:' ServerBootDrive
  108.            End
  109.       Else Do
  110.              Say '! Error: could not determine the Bootdrive'
  111.              Return
  112.            End
  113.  
  114.  /* Get NET.ACC size */
  115.     NetAccSize = Stream('\\'ServerName'\ibmlan$\Accounts\net.acc', 'C', 'Query Size')
  116.     If Trace Then Say '> NetAccSize:' NetAccSize
  117.  
  118.  /* Get Time */
  119.     RC = NetMisc(700, 'VarRet', '\\'ServerName)
  120.     ActTime = ' ' ||,
  121.               VarRet.Tod_Year  || '-' ||,
  122.               VarRet.Tod_Month || '-' ||,
  123.               VarRet.Tod_Day,
  124.               VarRet.Tod_Hours || ':' ||,
  125.               Right(VarRet.Tod_Mins,2,'0') || ':' ||,
  126.               Right(VarRet.Tod_Secs,2,'0')
  127.     If Trace Then Say '> ActTime:' ActTime
  128.  
  129.  /* Get HPFS386 Info */
  130.  
  131.     UseAllMem = '   '
  132.     Cache     = '     '
  133.     Heap      = '     '
  134.  
  135.     If SysFileSearch('useallmem', '\\'ServerName'\'ServerBootDrive'$\ibm386fs\hpfs386.ini', 'Stem') = 0
  136.       Then Do j = 1 to Stem.0
  137.              Parse Upper Value Stem.j With Begin '=' End
  138.              If Left(Strip(Begin),1) = ';'
  139.                Then Nop
  140.                Else UseAllMem = Strip(End)
  141.              If Trace Then Say '> UseAllMem:' UseAllMem
  142.            End
  143.       Else Nop
  144.  
  145.     If SysFileSearch('cachesize', '\\'ServerName'\'ServerBootDrive'$\ibm386fs\hpfs386.ini', 'Stem') = 0
  146.       Then Do j = 1 to Stem.0
  147.              Parse Value Stem.j With Begin '=' End
  148.              If Left(Strip(Begin),1) = ';'
  149.                Then Nop
  150.                Else Cache = Strip(End)
  151.              If Trace Then Say '> Cache:' Cache
  152.            End
  153.       Else Nop
  154.  
  155.     If SysFileSearch('maxheap', '\\'ServerName'\'ServerBootDrive'$\ibm386fs\hpfs386.ini', 'Stem') = 0
  156.       Then Do j = 1 to Stem.0
  157.              Parse Value Stem.j With Begin '=' End
  158.              If Left(Strip(Begin),1) = ';'
  159.                Then Nop
  160.                Else Heap = Strip(End)
  161.              If Trace Then Say '> Heap:' Heap
  162.            End
  163.       Else Nop
  164.  
  165.  /* Get LAN Server Info */
  166.  
  167.     NET1 = '     '
  168.     NET2 = '     '
  169.     NET3 = '     '
  170.     NET4 = '     '
  171.     NET5 = '     '
  172.  
  173.     If SysFileSearch('NET1 =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  174.       Then Do j = 1 to Stem.0
  175.              Parse Upper Value Stem.j With Begin '=' Stack '$,' NIC ',' . ',' Sessions ',' .
  176.              If Left(Strip(Begin),1) <> ';'
  177.                Then Do
  178.                       If Left(Stack,2) = ' N'
  179.                         Then Stack = 'NB'
  180.                         Else Stack = 'TP'
  181.                       NET1 = NIC || Stack || Right(Sessions,3,'0')
  182.                       If Trace Then Say '> Net1:' Net1
  183.                     End
  184.                Else Nop
  185.            End
  186.       Else Nop
  187.  
  188.     If SysFileSearch('NET2 =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  189.       Then Do j = 1 to Stem.0
  190.              Parse Upper Value Stem.j With Begin '=' Stack '$,' NIC ',' . ',' Sessions ',' .
  191.              If Left(Strip(Begin),1) <> ';'
  192.                Then Do
  193.                       If Left(Stack,2) = ' N'
  194.                         Then Stack = 'NB'
  195.                         Else Stack = 'TP'
  196.                       NET2 = NIC || Stack || Right(Sessions,3,'0')
  197.                       If Trace Then Say '> Net2:' Net2
  198.                     End
  199.                Else Nop
  200.            End
  201.       Else Nop
  202.  
  203.     If SysFileSearch('NET3 =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  204.       Then Do j = 1 to Stem.0
  205.              Parse Upper Value Stem.j With Begin '=' Stack '$,' NIC ',' . ',' Sessions ',' .
  206.              If Left(Strip(Begin),1) <> ';'
  207.                Then Do
  208.                       If Left(Stack,2) = ' N'
  209.                         Then Stack = 'NB'
  210.                         Else Stack = 'TP'
  211.                       NET3 = NIC || Stack || Right(Sessions,3,'0')
  212.                       If Trace Then Say '> Net3:' Net3
  213.                     End
  214.                Else Nop
  215.            End
  216.       Else Nop
  217.  
  218.     If SysFileSearch('NET4 =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  219.       Then Do j = 1 to Stem.0
  220.              Parse Upper Value Stem.j With Begin '=' Stack '$,' NIC ',' . ',' Sessions ',' .
  221.              If Left(Strip(Begin),1) <> ';'
  222.                Then Do
  223.                       If Left(Stack,2) = ' N'
  224.                         Then Stack = 'NB'
  225.                         Else Stack = 'TP'
  226.                       NET4 = NIC || Stack || Right(Sessions,3,'0')
  227.                       If Trace Then Say '> Net4:' Net4
  228.                     End
  229.                Else Nop
  230.            End
  231.       Else Nop
  232.  
  233.     If SysFileSearch('NET5 =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  234.       Then Do j = 1 to Stem.0
  235.              Parse Upper Value Stem.j With Begin '=' Stack '$,' NIC ',' . ',' Sessions ',' .
  236.              If Left(Strip(Begin),1) <> ';'
  237.                Then Do
  238.                       If Left(Stack,2) = ' N'
  239.                         Then Stack = 'NB'
  240.                         Else Stack = 'TP'
  241.                       NET5 = NIC || Stack || Right(Sessions,3,'0')
  242.                       If Trace Then Say '> Net5:' Net5
  243.                     End
  244.                Else Nop
  245.            End
  246.       Else Nop
  247.  
  248.     If SysFileSearch('AUTODISCONNECT =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  249.       Then Do j = 1 to Stem.0
  250.              Parse Value Stem.j With Begin '=' End
  251.              If Left(Strip(Begin),1) = ';'
  252.                Then Nop
  253.                Else AutoDisc = Strip(End)
  254.              If Trace Then Say '> AutoDisc:' AutoDisc
  255.            End
  256.       Else Nop
  257.  
  258.     If SysFileSearch('MAXUSERS =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  259.       Then Do j = 1 to Stem.0
  260.              Parse Value Stem.j With Begin '=' End
  261.              If Left(Strip(Begin),1) = ';'
  262.                Then Nop
  263.                Else MaxUsers = Strip(End)
  264.              If Trace Then Say '> MaxUsers:' MaxUsers
  265.            End
  266.       Else Nop
  267.  
  268.     If SysFileSearch('MAXCONNECTIONS =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  269.       Then Do j = 1 to Stem.0
  270.              Parse Value Stem.j With Begin '=' End
  271.              If Left(Strip(Begin),1) = ';'
  272.                Then Nop
  273.                Else MaxConn = Strip(End)
  274.              If Trace Then Say '> MaxConn:' MaxConn
  275.            End
  276.       Else Nop
  277.  
  278.     If SysFileSearch('MAXSHARES =', '\\'ServerName'\ibmlan$\ibmlan.ini', 'Stem') = 0
  279.       Then Do j = 1 to Stem.0
  280.              Parse Value Stem.j With Begin '=' End
  281.              If Left(Strip(Begin),1) = ';'
  282.                Then Nop
  283.                Else MaxShares = Strip(End)
  284.              If Trace Then Say '> MaxShares:' MaxShares
  285.            End
  286.       Else Nop
  287.  
  288.  /* Get MPTS Balance parameter */
  289.  
  290.     If SysFileSearch('BALANCE', '\\'ServerName'\'ServerBootDrive'$\ibmcom\protocol.ini', 'Stem') = 0
  291.       Then Do j = 1 to Stem.0
  292.              Parse Value Stem.j With Begin '=' End
  293.              If Left(Strip(Begin),1) = ';'
  294.                Then Nop
  295.                Else Balance = Strip(End)
  296.              If Trace Then Say '> Balance:' Balance
  297.            End
  298.       Else Nop
  299.  
  300.     OutText = OutText Right(Trunc(Time('E'),2),5) ';' ||,
  301.                       Right(ServerRole,5)         ';' ||,
  302.                       Right(NetAccSize,8)         ';' ||,
  303.                       Left(ActTime,20)            ';' ||,
  304.                       Center(Balance,8)           ';' ||,
  305.                       Right(Cache,7)              ';' ||,
  306.                       Right(UseAllMem,4)          ';' ||,
  307.                       Right(Heap,6)               ';' ||,
  308.                       Right(Net1,7)               ';' ||,
  309.                       Right(Net2,7)               ';' ||,
  310.                       Right(Net3,7)               ';' ||,
  311.                       Right(Net4,7)               ';' ||,
  312.                       Right(Net5,7)               ';' ||,
  313.                       Right(AutoDisc,5)           ';' ||,
  314.                       Right(MaxUsers,9)           ';' ||,
  315.                       Right(MaxConn,8)            ';' ||,
  316.                       Right(MaxShares,10)         ';'
  317.  
  318.    'net use \\'ServerName'\'Left(ServerBootDrive,1)'$ /d >nul'
  319.    'net use \\'ServerName'\ipc$ /d >nul'
  320.    'net use \\'ServerName'\ibmlan$ /d >nul'
  321.  
  322.     Return
  323.  
  324.  INIT:/* --------------------------------------------------------------------*/
  325.  
  326.    '@echo off'
  327.  
  328.     If Value('TREES',,'OS2Environment') = ''           /* Check for Tracing*/
  329.       Then Trace = 0
  330.       Else Trace = 1
  331.  
  332.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  333.  
  334.     If RxFuncQuery('SysLoadFuncs')
  335.       Then Do
  336.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  337.              Call SysLoadFuncs
  338.            End
  339.       Else Nop
  340.  
  341.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  342.     PPath = Translate(Value('PATH',,'OS2Environment'))
  343.     x = Pos('\IBMLAN\NETPROG;', PPath) -2
  344.     If x > 0
  345.       Then LSRDrive = SubStr(PPath, x, 2)
  346.       Else Do
  347.              Say '* Could not determine the Lan Requester path'
  348.              Exit
  349.            End
  350.  
  351.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  352.     If RxFuncQuery('LoadLSRXUTFuncs')
  353.       Then Do
  354.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  355.              Call LoadLsRxutFuncs
  356.            End
  357.       Else Nop
  358.  
  359.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  360.     If RxFuncQuery('RxLoadFuncs')
  361.       Then Do
  362.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  363.              Call RxLoadFuncs
  364.            End
  365.       Else Nop
  366.  
  367.     TempFile = LSRDrive'\ibmlan\lsbrowse.tmp'             /* Temporary file*/
  368.  
  369.     Return
  370.  
  371.  CHKFILE:/* -----------------------------------------------------------------*/
  372.  
  373.     Parse Arg File_To_Check
  374.  
  375.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  376.       Then Do
  377.              Say '! File not found:' File_To_Check
  378.              Exit
  379.            End
  380.       Else Nop
  381.  
  382.     Return
  383.  
  384.  LOGIT:/* -------------------------------------------------------------------*/
  385.  
  386.     Parse Arg OutFileName OutText
  387.  
  388.     If LineOut(OutFileName, OutText) = 0
  389.       Then Call Stream OutFileName, 'C', 'Close'
  390.       Else Say '! Error while writing:' OutFileName '07'x
  391.  
  392.     Return
  393.  
  394.  QUIT:/* --------------------------------------------------------------------*/
  395.  
  396.     Say '...Interupted by User...'
  397.  
  398.     Exit X2D('1604')
  399.  
  400.