title: vbscript reading Cisco switch interfaces
body: <p>Trying to create a script that will send a 'sh run | b interface' to a Cisco switch.  Write the output to an array.  Split that array with a vbcr so each line of the config is in a sep elemant of the array.</p>
  
  <p>I have tried to skin the cat many ways and still I am struggling.</p>
  
  <p>Logic in English:
  Send command to Cisco device
  Capture the output to an array
  define expected lines 'This are lines that are required under each 'interface' of the switch
  Match the 'interface' name and corresponding number and write it to a file.
  Check under that interface for the specific lines in the expected
  If it finds it, write the line &amp; ", YES"
  If it does not find it, write the line &amp; ", NO"
  Keep doing this until you do not find any more '^interface\s[FG][a-z].+' </p>
  
  <p>Output should look like this:
  Interface GigabitEthernet 0/2
   spanning-tree portfast, YES</p>
  
  <p>This is the sample code that is failing:</p>
  
  <pre><code>'These are the expected line (not being compared in the script below but is my intention to have it compare the matched elements)
  Dim vExpectedINT(4)
  vExpectedINT(0)  = "spanning-tree portfast"
  vExpectedINT(1)  = "switchport access vlan 17"
  vExpectedINT(2)  = "switchport mode access"
  vExpectedINT(3)  = "ip mtu 1400"    
  
  
  'objStream.Write "######################################################### " &amp; vbcrlf
  'objStream.Write "#                  I N T E R F A C E                    # " &amp; vbcrlf
  'objStream.Write "######################################################### " &amp; vbcrlf
  
  
  nCount = 0
  vConfigLines = Split(strResultsINT, vbcr)
  
  Set re = new RegExp
  re.Global = False
  re.IgnoreCase = True
  re.Multiline = False
  re.Pattern = "^interface [FG]"
  
  ' Regex Ex Definition
  Set re2 = new RegExp
  re2.Global = False
  re2.IgnoreCase = True
  re2.Multiline = False
  re2.Pattern = "\sspanning-tree\sportfast"
  
  ' Regex Ex Definition
  Set re3 = new RegExp
  re3.Global = False
  re3.IgnoreCase = True
  re3.Multiline = False
  re3.Pattern = "ip\smtu\s1400"
  
  Set re4 = new RegExp
  re4.Global = False
  re4.IgnoreCase = True
  re4.Multiline = False
  re4.Pattern = "!"
  
  ' Compares the information
  x = 1
  Do While x &lt;= Ubound(vConfigLines) - 1 do 
      MsgBox chr(34) &amp; strLine &amp; chr(34)
      If re.Test(vConfigLines(x)) Then
          ' Write data to not expected section
          x=x+1
          do
              If ! re4.Test(vConfigLines(x)) Then
                  MsgBox vConfigLines(x)
                  'objStream.Write vConfigLines(x) &amp; vbcr
                  elseif re2.Test(vConfigLines(x)) Then
                  MsgBox vConfigLines(x)
                  elseif re3.Test(vConfigLines(x)) Then
                  MsgBox vConfigLines(x)
              else
                  exit do
              end if
              x=x+1
          loop
          end IF
     End If
  Loop    
  </code></pre>
  
  <p>This is a sample of the vConfigLines output:</p>
  
  <p>There could be 48+ port per switch.</p>
  
  <pre><code>interface FastEthernet1/0/1
   switchport access vlan 127
   switchport mode access
   switchport voice vlan 210
   srr-queue bandwidth share 10 10 60 20
   srr-queue bandwidth shape 0 3 0 0
   priority-queue out 
   mls qos trust cos
   auto qos voip trust 
   spanning-tree portfast
  !
  interface FastEthernet1/0/2
   switchport access vlan 127
   switchport mode access
   switchport voice vlan 210
   srr-queue bandwidth share 10 10 60 20
   srr-queue bandwidth shape 0 3 0 0
   priority-queue out 
   mls qos trust cos
   auto qos voip trust 
   spanning-tree portfast
  !
  interface FastEthernet1/0/3
   switchport access vlan 127
   switchport mode access
   switchport voice vlan 210
   srr-queue bandwidth share 10 10 60 20
   srr-queue bandwidth shape 0 3 0 0
   priority-queue out 
   mls qos trust cos
   auto qos voip trust 
   spanning-tree portfast
  </code></pre>