Remembering Network Devices
A few years back when starting a new role providing 3rd Level support for an international network with over one hundred devices in my remit, it became apparent very quickly I was going to struggle to remember all the IP addresses in a few days or even the host names for that matter. There was no standard tools being use to connect all the devices, Windows XP telnet seem to be the tool of choice.
Most of the devices had some standards naming conventions. Like site code and type of device. So Lon_SW1 would be switch 1 in London. I decided to dust of my scripting skills and make life easier for myself.
Once you† run the script you get prompted for some characters that make up the device name. So if i type “lon” not case-sensitive and hit enter then all the London devices are displayed, then chose the device from the numbered list and it will startup the putty session.
There are 3 bits of code to make this work
- DevAccess.cmd ñ this is the Windows CMD file to call the VBscript
- DevAccess0.1.vbs ñ this the main code
- Devlist.txt ñ list of devices, make sure you do not create any duplicates as it will not work,
Put them in a directory on your Windows PC and create a shortcut to DevAccess.cmd. You will need to download kitty.exe (http://www.9bis.net/kitty/) and put it in the same directory.
I had previously used putty at work without port number and used command line “putty -protocol ipaddress”, however when I wrote this post I needed to use “ipaddress:port number” †to access my lab console and changed my command line to “putty protocol://ipaddress:port” †which is ok for telnet; quite rightly Ben Johnson pointed out that putty does not support ssh using this command line format so I have†updated the code to use kitty.exe instead, which seems to work fine.
Here is a quick demo
REM **** Runs Scipt to Search and Connect to Devices
REM **** This works of the devlist.txt located on
REM **** c:program filesdevaccess
REM **** also have Putty.exe in the same directory as the script
ì%SYSTEMROOT%SYSTEM32CSCRIPT.EXEî //nologo ì%~dp0DevAccess0.1.vbsî
Set objFSO = CreateObject("Scripting.FileSystemObject")
set oMyDevs = CreateObject("Scripting.Dictionary")
Const ForReading = 1
if objFSO.FileExists(inifile) then
Set objFile = objFSO.OpenTextFile(inifile, ForReading)
Do Until objFile.AtEndOfStream
strdev = objFile.ReadLine
aDeviceInfo = Split(strdev, ",", -1, 1)
oMyDevs.Add aDeviceInfo(0),"kitty " & aDeviceInfo(2) & "://" & aDeviceInfo(1) & " -title " & aDeviceInfo(0)
wscript.echo aDeviceInfo(0),"kitty " & aDeviceInfo(2) & "://" & aDeviceInfo(1) & " -title " & aDeviceInfo(0)
MsgBox inifile & " is missing, copy it from MyNMS",0,"Missing Device Master List"
MyDevices = oMyDevs.Keys
do while 1
devicematch = InputBox("Enter device characters","Search for Device (enter x to quit)",,,0)
if ucase(devicematch)="X" then
Wscript.Echo "======== Device List ============================================"
For Each strDevice in MyDevices
if instr(1 ,ucase(strDevice),ucase(devicematch),1) then
Wscript.Echo index & " ) " & strDevice & " " & oMyDevs.Item(strDevice)
strInputChoice=strInputChoice & index & " ) " & strDevice &vbCR &vbLF
redim preserve startkitty(index)
if index >1 then
if ucase(opendevice)="X" then
if isnumeric(opendevice) then
if int(opendevice) > 0 and int(opendevice) <=index then
wscript.echo "Starting SSH sessions to " & startkitty(opendevice)
elseif index=1 then
wscript.echo "Starting SSH sessions to " & startkitty(1)
wscript.echo "No Devices Found containing " & devicematch
A quick method of navigating you way around devices, and if you change the telnet to ssh that should work too; the list above is just my LAB access at home, I do not want to be publishing customer site information.