Page 1 of 1

Controlling Cisco Switch from WD

PostPosted: Tue Nov 07, 2017 6:31 am
by djrappa
Hi
I have an application where I need to reconfigure the VLAN assignment of a cisco switch port on the fly.

I need to be able to this from within Widget Designer. Does anyone know of a way I could send commands to the Cisco SG500 switch from Widget Designer to achieve this?

Usually control of the switch settings is via a web interface or via Telnet...

Re: Controlling Cisco Switch from WD

PostPosted: Tue Nov 07, 2017 2:01 pm
by Dennis Kuypers
Hello,

try to do whatever you need to do with putty or another console application that connects via telnet and then you can port it to the widget designer.

Regards
Dennis

Re: Controlling Cisco Switch from WD

PostPosted: Tue Nov 07, 2017 10:59 pm
by djrappa
Can you elaborate further as to what you mean by 'port it to WD'?

Re: Controlling Cisco Switch from WD

PostPosted: Wed Nov 08, 2017 1:00 am
by justyn roy
Create a Connection in WD with the Port and address that works in Putty.

Use scripts to send the same commands that work in Putty from WD.

Re: Controlling Cisco Switch from WD

PostPosted: Wed Nov 08, 2017 3:19 am
by djrappa
Ah yes that makes total sense... wasn't sure if Porting was literally meaning Port in this case.

Re: Controlling Cisco Switch from WD

PostPosted: Wed Nov 08, 2017 12:14 pm
by Dennis Kuypers
Hello,

I was saying that you should find out what you have to do in putty to get the results you want and then do the same in WD.

ex.: In putty you do
Code: Select all
{DoStuff}<press enter>


then in WD you do
Code: Select all
TCPSend(1, "{DoStuff}\n")



Dennis

I wasn't referring to a "network port", i meant this:
verb: port; 3rd person present: ports; past tense: ported; past participle: ported; gerund or present participle: porting
1. COMPUTING
transfer (software) from one system or machine to another.
"the software can be ported to practically any platform"

Re: Controlling Cisco Switch from WD

PostPosted: Fri Nov 24, 2017 12:42 pm
by djrappa
Sorry yes I was understanding that.

I found some unusual behaviour from the TCP send function though (I could monitor this with a receive node). Every time I sent a string to the switch, it wouldn't see this first character. I could work around this with a dummy character but unfortunately the switch would not let me login even when receiving the correct info from WD. So there must be something within the authentication of the Telnet connection that won't allow WD to login to the switch.

A workaround is to call an external script (for example Visual Basic) from within WD that carried out the config operation in the switch.

Re: Controlling Cisco Switch from WD

PostPosted: Fri Nov 24, 2017 7:23 pm
by Dennis Kuypers
Hey,

we have a SG500-52 that we could test with. Can you provide the port number and the scripts that you are using?

Regards
Dennis

Re: Controlling Cisco Switch from WD

PostPosted: Sun Nov 26, 2017 1:07 am
by djrappa
Unfortunately I don't have the scripts with me as they are onsite, but I will forward them over later next week when I have access to the machine they are on.

Thanks

Re: Controlling Cisco Switch from WD

PostPosted: Tue Dec 12, 2017 2:31 am
by djrappa
So this is the exact .vbs script I'm using to accomplish the task.

If I attempt to recreate in WD as I said the first character is being cut off and regardless of a correct user name and password being entered the switch fails to login so the script can continue...

Code: Select all
Set cloner = CreateObject("WScript.Shell")
cloner.run"cmd"
WScript.Sleep 500

cloner.SendKeys"telnet 192.168.1.213"
cloner.SendKeys("{Enter}")
WScript.Sleep 500

cloner.SendKeys"cisco"
cloner.SendKeys("{Enter}")
WScript.Sleep 500

cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"config"
cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"interface ge1/2"
cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"switchport access vlan 7"
cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"exit"
cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"exit"
cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"exit"
cloner.SendKeys("{Enter}")
WScript.Sleep 500

cloner.SendKeys("{Enter}")
WScript.Sleep 200

cloner.SendKeys"exit"
cloner.SendKeys("{Enter}")
WScript.Sleep 200