home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / PCDUO / data1.cab / Script_Samples / FINDALL.SCP < prev    next >
Encoding:
Text File  |  2003-11-28  |  3.0 KB  |  106 lines

  1. // FINDALL.SCP Sample Script
  2. // Copyright (c) 2002, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. //  7.0 29-Jan-02 DB  - Created, using LOOKUP.SCP.
  7.  
  8. //  This is a simple script which can find all Clients in a 
  9. //  Group, find all Available Clients, or list all Known Clients.
  10. //  For each Client found, it calls ProcessClient, which can 
  11. //  be modified to do whatever you want...
  12.  
  13. //  Predefined variables:
  14. //    ClientName = "" Template name for Lookup (use "*" for any)
  15. //    GroupName = "" Lists all Clients in this Group
  16. //    Password = "GBBLLYDGKK" Encrypted password for remote network
  17. //    Username = "SCRIPTING/GBBLLYDGKK" Username and password for Connect
  18.  
  19. Function Main ()
  20.  Dim ClientList, ClientCount, ClientTotal
  21.  Dim CurClient, ClientName, GroupName, Username
  22.  
  23.   // Initialise counter variables
  24.  
  25.   ClientCount = 0
  26.   ConnectErrors = 0
  27.   TotalErrors = 0
  28.  
  29.   // Trim predefined variables before use
  30.  
  31.   ClientName = Trim (ClientName)
  32.   GroupName = Trim (GroupName)
  33.   Username = Trim (Username)
  34.  
  35.   SetTransport (T_TCPIP)
  36.  
  37.   //  See what we are supposed to do 
  38.   //  and get any Clients into a list
  39.  
  40.   If GroupName != "" Then
  41.     Print "Selecting all Clients in Group: ", GroupName
  42.     ClientTotal = GetClientsInGroup (GroupName, ClientList)
  43.   Else
  44.     If ClientName != "" Then
  45.       Print "Browsing the Network for Clients. Please wait..."
  46.       If ClientName = "*" Then
  47.         ClientTotal = LookUp ("", ClientList)
  48.       Else
  49.         ClientTotal = LookUp (ClientName, ClientList)
  50.       Endif
  51.     Else
  52.       Print "Listing all Known Clients"
  53.       ClientTotal = GetAllClients (ClientList)
  54.     Endif
  55.   Endif
  56.  
  57.   If ClientTotal > 0 Then
  58.     Print CStr (ClientTotal), " Clients found"
  59.  
  60.     // Now, work through the list of Clients
  61.  
  62.     ClientCount = 0
  63.     ClientNum = 1
  64.  
  65.     For Each CurClient in ClientList
  66.       ClientName = GetClientName (CurClient)
  67.  
  68.       If ProcessClient (CurClient, ClientName, Username) Then
  69.         Print "Client ", ClientNum, " <", ClientName, "> processed successfully"
  70.         ClientCount = ClientCount + 1
  71.       Else
  72.         Print "Client ", ClientNum, " <", ClientName, "> processing FAILED"
  73.         TotalErrors = TotalErrors + 1
  74.       EndIf
  75.       ClientNum = ClientNum + 1
  76.     Next
  77.   Else
  78.     Print "No Clients found"
  79.   Endif
  80.  
  81.   //  Print a summary
  82.  
  83.   Print ""
  84.   Print "Summary:"
  85.   Print "  Total Clients ", ClientTotal
  86.   Print "  Clients found ", ClientCount
  87.   Print "  Total Errors ", TotalErrors
  88. End Function
  89.  
  90. //  ProcessClient is a generic Function which can be altered 
  91. //  to do almost anything on one Client.
  92.  
  93. Function ProcessClient (CurClient, ClientName, Username)
  94.   Print "Processing Client <", ClientName, ">"
  95.  
  96.   If Connect (CurClient, Username) == TRUE Then
  97.     Print "Connected to ", ClientName
  98.     Disconnect (CurClient)
  99.     ProcessClient = TRUE
  100.   Else
  101.     Print "Unable to connect to ", ClientName
  102.     Print "Error ", LASTERROR, " = ", LASTERRORSTRING
  103.     ProcessClient = FALSE
  104.   EndIf
  105. End Function
  106.