home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lsdisk.cmd < prev    next >
OS/2 REXX Batch file  |  2000-12-13  |  6KB  |  184 lines

  1. /*---------------------------------------------------------------------------*\
  2. |   Get DiskInformation from servers          (C) Alain Rykaert - NOV98-DEC99 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.02a (C) AR - DEC99'
  5.     Say '* LSDISK Version' Version
  6.  
  7.     Signal On Halt Name Quit
  8.  
  9.     Call Init                                 /* init dll's and other stuff*/
  10.  
  11.     Parse Upper Arg DCName OutFileName
  12.  
  13.     If DCName = '' | OutFileName = ''
  14.       Then Do
  15.              Say '*'
  16.              Say '* Get Disk Information from Servers'
  17.              Say '*'
  18.              Say '* Usage: LSDISK {DCName} {OutputFileName}'
  19.              Say '*'
  20.              Say '* Sample: LSDISK \\BEDDC01 LSDISK.CSV'
  21.              Say '*'
  22.              Exit
  23.            End
  24.       Else Nop
  25.  
  26.     DCName = Strip(DCName,'L','\')
  27.     Say '* Server Name:' '\\'DCName
  28.     Say '* Output FileName:' OutFileName
  29.  
  30.     RC = NetGetInfo(370, 'ServerModalInfo', '\\'DCName)  /* get server role*/
  31.     If RC = 0
  32.       Then Do
  33.              ServerRole = ServerModalInfo.Role
  34.              If WordPos('Primary', ServerRole) > 0     /* check server role*/
  35.                Then Nop
  36.                Else Do
  37.                       Say '! This is not a Primary Domain Controller' '07'x
  38.                       Exit
  39.                     End
  40.            End
  41.       Else Say RC
  42.  
  43.     RC = NetGetInfo(340, 'ServerName', '\\'DCName, 'Servers')/* get all servers*/
  44.     If RC = 0
  45.       Then Do
  46.             'if exist' OutFileName 'del' OutFileName
  47.              OutText = '***' Date() Time() '*** LSDISK Version:' Version
  48.              Call Logit OutFileName OutText
  49.              Call RxStemSort 'ServerName'
  50.              Say '* Total defined servers:' ServerName.0
  51.  
  52.              Do i = 1 to ServerName.0
  53.                OutText = Copies('-',75)
  54.                Call Logit OutFileName OutText
  55.                Counter = '('Right(i,Length(ServerName.0))'/'Right(ServerName.0,Length(ServerName.0))')'
  56.                OutText = '* ServerName:' Counter Left(ServerName.i,8)
  57.                Call CharOut ,OutText
  58.                Call Logit OutFileName OutText
  59.                If NetGetInfo(370, 'ServerModalInfo', '\\'ServerName.i) = 0 &,
  60.                  Stream('\\'ServerName.i'\ibmlan$\ibmlan.ini', 'C', 'Query Exists') <> ''
  61.                  Then Call GetDisk ServerName.i
  62.                  Else Say '> not found'
  63.              End
  64.              OutText = Copies('-',75)
  65.              Call Logit OutFileName OutText
  66.  
  67.              Say '* Done. File' OutFileName 'created'
  68.            End
  69.       Else Say RC
  70.  
  71.     Exit
  72.  
  73.  GETDISK:/* ---------------------------------------------------------------*/
  74.  
  75.     Parse Arg ServerName
  76.  
  77.    'if not exist' LSRDrive'\ibmlan\tmp md' LSRDrive'\ibmlan\tmp'
  78.     TempFile = LSRDrive'\ibmlan\tmp\lsdisk.tmp'           /* Temporary file*/
  79.  
  80.     If Stream('\\'ServerName'\ibmlan$\netprog\free.exe', 'C', 'Query Exists') = ''
  81.       Then 'copy free.exe \\'ServerName'\ibmlan$\netprog\ >nul'
  82.       Else Nop
  83.  
  84.    'net admin \\'ServerName '/c free.exe >' TempFile
  85.     Call Stream TempFile, 'C', 'Close'
  86.  
  87.     LogText = ''
  88.     If Stream(TempFile, 'C', 'Query Size') > 0
  89.       Then Do While Lines(TempFile)
  90.              LLine = LineIn(TempFile)
  91.              If Left(LLine, 4) = 'FREE' | Left(LLine,1) = '='
  92.                Then Nop
  93.                Else Do
  94.                       LogText = LLine
  95.                    /* Say LogText */
  96.                       Call Logit OutFileName LogText
  97.                     End
  98.            End
  99.       Else Do
  100.              Say '! Error: tempfile' TempFile 'is not valid' '07'x
  101.              Return
  102.            End
  103.     Call Stream TempFile, 'C', 'Close'
  104.  
  105.    'net use \\'ServerName'\c$      /d >nul 2>nul'
  106.    'net use \\'ServerName'\d$      /d >nul 2>nul'
  107.    'net use \\'ServerName'\ipc$    /d >nul 2>nul'
  108.    'net use \\'ServerName'\ibmlan$ /d >nul 2>nul'
  109.  
  110.     Say '* OK'
  111.  
  112.     Return
  113.  
  114.  INIT:/* --------------------------------------------------------------------*/
  115.  
  116.    '@echo off'
  117.  
  118.     BootDrive = Left(Value('Comspec',,'OS2Environment'),2)
  119.  
  120.     If RxFuncQuery('SysLoadFuncs')
  121.       Then Do
  122.              Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  123.              Call SysLoadFuncs
  124.            End
  125.       Else Nop
  126.  
  127.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  128.     PPath = Translate(Value('PATH',,'OS2Environment'))
  129.     x = Pos('\IBMLAN\NETPROG;', PPath) -2
  130.     If x > 0
  131.       Then LSRDrive = SubStr(PPath, x, 2)
  132.       Else Do
  133.              Say '* Could not determine the Lan Requester path'
  134.              Exit
  135.            End
  136.  
  137.     Call ChkFile LSRDrive'\ibmlan\netlib\lsrxut.dll'
  138.     If RxFuncQuery('LoadLSRXUTFuncs')
  139.       Then Do
  140.              Call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs'
  141.              Call LoadLsRxutFuncs
  142.            End
  143.       Else Nop
  144.  
  145.     Call ChkFile BootDrive'\os2\dll\rxutils.dll'
  146.     If RxFuncQuery('RxLoadFuncs')
  147.       Then Do
  148.              Call RxFuncAdd 'RxLoadFuncs', 'RXUTILS', 'RxLoadFuncs'
  149.              Call RxLoadFuncs
  150.            End
  151.       Else Nop
  152.  
  153.     Return
  154.  
  155.  CHKFILE:/* -----------------------------------------------------------------*/
  156.  
  157.     Parse Arg File_To_Check
  158.  
  159.     If Stream(File_To_Check, 'C', 'Query Exists') = ''
  160.       Then Do
  161.              Say '! File not found:' File_To_Check
  162.              Exit
  163.            End
  164.       Else Nop
  165.  
  166.     Return
  167.  
  168.  LOGIT:/* -------------------------------------------------------------------*/
  169.  
  170.     Parse Arg OutFileName OutText
  171.  
  172.     If LineOut(OutFileName, OutText) = 0
  173.       Then Call Stream OutFileName, 'C', 'Close'
  174.       Else Say '! Error while writing:' OutFileName '07'x
  175.  
  176.     Return
  177.  
  178.  QUIT:/* --------------------------------------------------------------------*/
  179.  
  180.     Say '...Interupted by User...'
  181.  
  182.     Exit X2D('1604')
  183.  
  184.