Solved

VB Programs for telneting into CISCO switch.

Posted on 2004-09-20
6
847 Views
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.
0
Comment
Question by:Albert1809
  • 3
  • 2
6 Comments
 
LVL 8

Assisted Solution

by:mladenovicz
mladenovicz earned 250 total points
Comment Utility
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
Next
If bolfound Then
    objShell.Exec "Telnet " & arrSwitches(intMatch)
Else
    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.
0
 
LVL 1

Author Comment

by:Albert1809
Comment Utility
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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
Comment Utility
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.  
0
 
LVL 1

Author Comment

by:Albert1809
Comment Utility
Half of the stuff on the script I don't remember. Can you point me to some breif tutorials?
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

18 Experts available now in Live!

Get 1:1 Help Now