View Single Post
  #3  
Old 11-04-2013, 03:18 PM
olivebranch2006 olivebranch2006 is offline
Registered User
 
Join Date: Apr 2010
Posts: 35
Still a problem

Hello,

I have read the guide but it has been a while. Now that I've added a bunch of tabs and tried placing each function in a sub, I'm still getting the same error. Can you please advise?

Here is the new version:

Code:
crt.Screen.Synchronous = True

main

sub main()

Dim shell
Set shell = CreateObject("WSCript.Shell")

'Declare Global Strings
Dim mySwPort
Dim phonemac
Dim mySwitchCount
							  
'count the number of switches
crt.Screen.Send "sh int status" & vbCr

crt.Screen.WaitForStrings "4/0/48","3/0/48","2/0/48","1/0/48"
Select Case crt.Screen.MatchIndex
	Case 1
		mySwitchCount = 4
	Case 2
		mySwitchCount = 3
	Case 3
		mySwitchCount = 2
	Case 4
		mySwitchCount = 1
End select

myPortNum = 1

If mySwitchCount = 1 Then 3750x48-1

If mySwitchCount = 2 Then 
	3750x48-1
	3750x48-2
End If

If mySwitchCount = 3 Then
	3750x48-1
	3750x48-2
	3750x48-3
End If

If mySwitchCount = 4 Then
	3750x48-1
	3750x48-2
	3750x48-3
	3750x48-4
End If

If crt.Session.Connected Then crt.Session.Disconnect
msgbox "Finished Programming"
End If


End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Incrementing Loop for each port of a switch

Sub F1
Function 3750x48-1
For i to 48
	crt.Screen.Send "terminal length 0" & vbCr
	crt.Screen.WaitForString "#"
	crt.Screen.Send "sh cdp ne int g1/0/" & myPortNum & vbCr
	crt.Screen.WaitForStrings "IP Phone", "VG224", "DMP", "Ieee PD", "AIR-CAP", "#"
	Select Case crt.Screen.MatchIndex
		Case 1
			'Found a phone, secure it
			screenrow = crt.Screen.CurrentRow
			phonemac = crt.Screen.Get(screenrow, 3, screenrow, 15)
			crt.Screen.Send "config t" & vbCr
			crt.Screen.WaitForString "#"
			crt.Screen.Send "int g1/0/" & myPortNum & vbCr
			crt.Screen.WaitForString "#"
			crt.Screen.Send "switchport port-security max 1 vlan voice" & vbCr
			crt.Screen.WaitForString "#"
			crt.Screen.Send "switchport port-security violation shutdown vlan" & vbCr
			crt.Screen.WaitForString "#"
			crt.Screen.Send "switchport port-security mac-address " & phonemac & " vlan voice" & vbCr
			crt.Screen.WaitForString "#"
			crt.screen.send "end" & vbcr
		Case 2
			'Found a VG224, ignore the port
		Case 3
			'Found a DMP, ignore the port
		Case 4
			'don't remember what this means LOOK INTO THIS can be paging zone controller
		Case 5
			'Found an LWAP, ignore the port
		Case 6
			crt.Screen.Send "sh power inline int g1/0/" & myPortNum & vbCr
			'Ieee PD is a Paging Zone Controller. skip these ports
			crt.Screen.WaitForStrings "IP Phone", "#", "Ieee PD"
			Select Case crt.Screen.MatchIndex
				Case 1
					'Phone already programmed, skip
				Case 2
					'No Phone, lock the port by removing voice vlan.  first identify the voice vlan
					crt.screen.send "sh run int g1/0/" & myPortNum & vbcr
					crt.screen.waitforstring "switchport voice vlan "
					phonevlan = Trim(crt.Screen.ReadString(vbcr))
					crt.screen.send "config t" & vbcr
					crt.screen.waitforstring "#"
					crt.Screen.Send "int g1/0/" & myPortNum & vbCr
					crt.screen.waitforstring "#"
					crt.screen.send "no switchport voice vlan " & phonevlan & vbcr
					crt.screen.waitforstring "#"
					crt.screen.send "end " & vbcr
					crt.screen.waitforstring "#"
				Case 3
					'Paging Zone Controller, skip the port
			end select
	end select
myPortNum = myPortNum + 1
End Function
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'function 3750x48-2
'end function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'function 3750x48-3
'end function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'function 3750x48-4
'end function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Last edited by rtb; 11-04-2013 at 03:35 PM.
Reply With Quote