Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2013, 05:03 PM
olivebranch2006 olivebranch2006 is offline
Registered User
 
Join Date: Apr 2010
Posts: 35
If Then with Function produces error

Hello,

This If Then End if statement with a function in it is producing the error:
VBScript Compilation error
Error: Expected Statement
Line: 45
If mySwitchCount = 1 Then 3750x48-1

Do you know why? Code is below.

Thanks!

Code:
main

sub main()

crt.Screen.Synchronous = True



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

'Declare Strings
dim mySwPort
dim phonemac
							  
'count the number of switches
Dim mySwitchCount
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
End If

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

If mySwitchCount = 3 _
then 3750x48-1 _
then 3750x48-2 _
then 3750x48-3 _
End If

If mySwitchCount = 4 _
then 3750x48-1 _
then 3750x48-2 _
then 3750x48-3 _
then 3750x48-4 _
End If



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


end sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Incrementing Loop for each port of a switch
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
crt.Screen.WaitForStrings "IP Phone", "#", "Ieee PD"
'Ieee PD is a Paging Zone Controller. skip these ports
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

function 3750x48-2
end function

function 3750x48-3
end function

function 3750x48-4
end function

Last edited by rtb; 11-01-2013 at 08:29 AM.
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:11 AM.