#1
|
|||
|
|||
Cisco Switch Port is Skipped
My project is tailored specifically to cisco switches. Once in a switch im having my Vbscript show the status of all interfaces then allowing me to mass send a command to all that is labled to a specific vlan.
The only issue i am having is for whatever reason no matter the size of the switch it will always skip interface 12. There are no configuration differences between these ports also. Please help me locate this bug. Code:
#$language = "VBScript" #$interface = "1.0" Sub Main() crt.Screen.Synchronous = True crt.Screen.Send "sh int statu" & chr(13) & vbcr crt.Screen.WaitForString vbcr strCompleteOutput = "" count = 0 Do crt.Screen.Send " " if count = 20 then exit do count = count + 1 Loop strResult = crt.Screen.ReadString("#") strCompleteOutput = strCompleteOutput & strResult Do filterInput = InputBox("Type the VLAN ID you want to use to filter interfaces. Leave blank to include all.", "Filter Interfaces") cmdInput = InputBox("Type the command you want to run on all interfaces identified by the text filter.", "Enter Command") userCheck = MsgBox("You want to run '" + cmdInput + "' on all interfaces that contain '" + filterInput + "'. Is this correct?",3,"Verify") If userCheck = 2 Then Exit Sub ElseIf userCheck = 6 Then Exit Do End If Loop strCompleteOutput = Replace(strCompleteOutput, _ vblf & vbcr & vbcr & " " & vbcr, vblf & vbcr) arrLines = Split(strCompleteOutput, vbCrLf) listBuffer = "int range " bufferCount = 0 output = "config t" + chr(13) For Each line In arrLines If Left(line,2) = "Gi" Or Left(line,2) = "Fa" Then If InStr(1,line," " + filterInput + " ",1) Then splitLine = Split(line) If bufferCount = 0 Then listBuffer = listBuffer + splitLine(0) ElseIf bufferCount < 5 Then listBuffer = listBuffer + "," + splitLine(0) ElseIf bufferCount = 5 Then output = output + listBuffer + chr(13) + cmdInput + chr(13) listBuffer = "int range " + splitLine(0) bufferCount = 0 End If bufferCount = bufferCount + 1 End If End If Next If bufferCount <> 0 Then output = output + listBuffer + chr(13) + cmdInput + chr(13) + "end" + chr(13) End If 'MsgBox output crt.Screen.Send output End Sub ######################## ##### Typical Output ##### Code:
Switch#sh int statu Port Name Status Vlan Duplex Speed Type Gi3/0/1 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/2 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/3 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/4 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/5 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/6 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/7 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/8 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/9 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/10 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/11 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/12 notconnect 210 auto auto 10/100/1000BaseTX Port Name Status Vlan Duplex Speed Type Gi3/0/13 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/14 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/15 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/16 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/17 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/18 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/19 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/20 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/21 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/22 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/23 notconnect 210 auto auto 10/100/1000BaseTX Gi3/0/24 notconnect 210 auto auto 10/100/1000BaseTX Port Name Status Vlan Duplex Speed Type Po1 CAN120 notconnect trunk auto auto Switch# config t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int range Gi3/0/1,Gi3/0/2,Gi3/0/3,Gi3/0/4,Gi3/0/5 Switch(config-if-range)#shut Switch(config-if-range)#$i3/0/6,Gi3/0/7,Gi3/0/8,Gi3/0/9,Gi3/0/10 Switch(config-if-range)#shut Switch(config-if-range)#$i3/0/11,Gi3/0/13,Gi3/0/14,Gi3/0/15,Gi3/0/16 Switch(config-if-range)#shut Switch(config-if-range)#$i3/0/17,Gi3/0/18,Gi3/0/19,Gi3/0/20,Gi3/0/21 Switch(config-if-range)#shut Switch(config-if-range)#int range Gi3/0/22,Gi3/0/23,Gi3/0/24 Switch(config-if-range)#shut Switch(config-if-range)#end Switch# Last edited by jdev; 04-19-2018 at 12:53 PM. Reason: Add CODE tags. |
Tags |
cisco , vbscript |
Thread Tools | |
Display Modes | Rate This Thread |
|
|