home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / lsconn.cmd < prev    next >
OS/2 REXX Batch file  |  1998-01-26  |  3KB  |  105 lines

  1. /*---------------------------------------------------------------------------*\
  2. |  Check Lan Server Connections               (C) Alain Rykaert - MAR96-DEC97 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '2.02'
  5.     Say '* LSCONN Version' Version
  6.  
  7.     Parse Upper Arg ServerName
  8.  
  9.     If ServerName = ''
  10.       Then Do
  11.              Say '*'
  12.              Say '* LAN Server Connections Statistics'
  13.              Say '*'
  14.              Say '* Usage: LSCONN {*} {ServerName}'
  15.              Say '*'
  16.              Say '* Sample: LSCONN \\BEDDC2'
  17.              Say '*'
  18.              Exit
  19.            End
  20.       Else Nop
  21.  
  22.     Call Init                                   /* load DLL's & other stuff*/
  23.  
  24.     If ServerName = '*'
  25.       Then Do
  26.              RC = NetGetInfo(350, 'WkstaInfo','')
  27.              If RC = 0
  28.                Then ServerName = WkstaInfo.ComputerName
  29.                Else Call ChkError RC
  30.            End
  31.       Else ServerName = ServerName
  32.  
  33.     ServerName = Strip(ServerName,'L','\')
  34.  
  35.     Say '* Server Name:' '\\'ServerName
  36.  
  37.     TotalConnections = 0
  38.     RC = NetEnumerate(180, 'Sessions', '\\'ServerName)
  39.     If RC = 0
  40.       Then Do
  41.              Do i = 1 to Sessions.0
  42.                Say Copies('-',65)
  43.                Say '*' i'/'Sessions.0 Sessions.i
  44.                RC = NetEnumerate(40, 'ConnInfo', '\\'ServerName, '\\'Sessions.i)
  45.                Say '* Connections =' ConnInfo.Num_Entries
  46.                TotalConnections = TotalConnections + ConnInfo.Num_Entries
  47.                Do j = 1 to ConnInfo.Num_Entries
  48.                  Say ' ' Left(ConnInfo.j.id,6) Left(connInfo.j.username,8) Left(connInfo.j.netname,8) Left(connInfo.j.type,20) Left(connInfo.j.num_opens,3) Left(connInfo.j.num_users,3) connInfo.j.time
  49.                End
  50.              End
  51.              Say Copies('-',65)
  52.              Say '* TotalConnections =' TotalConnections
  53.            End
  54.       Else Call ChkError
  55.  
  56.     Exit
  57.  
  58.  INIT:/* --------------------------------------------------------------------*/
  59.  
  60.    '@echo off'
  61.     BootDrive = Left(Value('COMSPEC',,'OS2ENVIRONMENT'),2)
  62.  
  63.     If RxFuncQuery('SysLoadFuncs')
  64.       Then Do
  65.              Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
  66.              Call SysLoadFuncs
  67.            End
  68.       Else Nop
  69.  
  70.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  71.     PPath = Value('PATH',,'OS2ENVIRONMENT')
  72.     x = Pos('IBMLAN\NETPROG', PPath) -3
  73.     If x > 0
  74.       Then LSRDrive = SubStr(PPath, x, 2)
  75.       Else Do
  76.              Say '* Could not determine the Lan Requester path' '07'x
  77.              Exit X2D('1604')
  78.            End
  79.  
  80.     If Stream(LSRDrive'\ibmlan\netlib\lsrxut.dll', 'C', 'Query Exists') <> ''
  81.       Then Do
  82.              If RxFuncQuery('LoadLSRXUTFuncs')
  83.                Then Do
  84.                       Call RxFuncAdd LoadLsRxutFuncs, LSRXUT, LoadLsRxutFuncs
  85.                       Call LoadLsRxutFuncs
  86.                     End
  87.                Else Nop
  88.            End
  89.       Else Do
  90.              Say '* Could not find' LSRDrive'\IBMLAN\NETLIB\LSRXUT.DLL' '07'x
  91.              Exit X2D('0800')
  92.            End
  93.  
  94.     Return
  95.  
  96.  CHKERROR:/* ----------------------------------------------------------------*/
  97.  
  98.     Parse Arg RCode
  99.  
  100.     Say '* Error:' RCode
  101.     Exit X2D('1600')
  102.  
  103.     Return
  104.  
  105.