VB Programs for telneting into CISCO switch.

Posted on 2004-09-20
Last Modified: 2012-06-27
At work we use dozens of cisco switches through out the building. We have to telnet into the them to make any changes. I have an idea to write a VB program that will allow me to just type in the floor and the location (east or west) and it will automatically run the command telnet switch_name. The naming  scheme for the switches are c6k5east, were 5 is the floor and east is the location.

I have taken VB in college, but it has been 1 1/2 years since i last used it. Can some one tell me in steps what I have to read, in steps, in order to complete my idea?

Any suggestions will help as well.
Question by:Albert1809
  • 3
  • 2

Assisted Solution

mladenovicz earned 250 total points
ID: 12102683
LVL 76

Expert Comment

by:David Lee
ID: 12102995
I don't know that you really need a Telnet app or even a VB program.  You can do this easily enough with a simple VBScript routine like this:

----- Script Tnet2Switch.Vbs
Dim objShell, arrNames, arrSwitches, intMatch, bolFound
Set objShell = CreateObject("Wscript.Shell")
strRequested = Wscript.Arguments.Item(0)
arrNames = Array("1east", "2east", "3east", "1west", "2west", "3west")
arrSwitches = Array("c6k1east", "c6k2east", "c6k3east", "c6k1west", "c6k2west","c6k3west")
For intMatch = 0 To UBound(arrNames)
    If strRequested = arrNames(intMatch) Then
        bolFound = True
        Exit For
    End If
If bolfound Then
    objShell.Exec "Telnet " & arrSwitches(intMatch)
    Wscript.Echo "Could not find a switch with the name (" & strRequested & ")."
End If
Set objShell = Nothing

----- End Script

All you need to do is edit the two arrays and put in the aliases for the switches in arrNames and the actual switch names in arrSwitches.  Then call the script like this:

    Tnet2Switch AliasName

The script will look for a matching switch and if it finds one it'll launch Telnet connecting to that switch.

Author Comment

ID: 12105488
Thanks for the code. But I wanted to refresh my memory on VB and also would like to created a simple exe that would just ask me which router I want and just run it in telnet. Makes it easier for me and my staff to just have a program with a drop down list of all our switchs running. It's easier then starting the command prompt, and typing in "telnet switchname". But I'm mainly doing this to refresh my memery and get me more firmilur will VB. Once again, thankx for the code.
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

LVL 76

Accepted Solution

David Lee earned 250 total points
ID: 12105945
I understand.  If you want a full-blown Telnet client written in VB, then the first link mladenovicz posted is probably your best bet.  You could modify it to add a dropdown list of switch names.  If instead you want a Telnet launcher, but one written in pure VB, then you can take some concepts from the sample I posted.  For example parallel lists, one to display the name of the switch for the user's viewing and another to hold the actual switch name;  using the WshShell to shell out and run the Telnet app once a switch is selected.  Another nice touch would be to read the switch names in from a file so that changes in switch names or locations don't force you to redo your application.  

Author Comment

ID: 12106187
Half of the stuff on the script I don't remember. Can you point me to some breif tutorials?
LVL 76

Expert Comment

by:David Lee
ID: 12108394

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now