Telnet login script
Does anyone have a simple telnet login script I can use as a base to edit? I simply want to have it auto-login. This is to a cisco router, so will need to send the initial CR, wait for "sword:", send the password, then send "en" (CR), and finally wait for "sword:" again and send the enable password.
The help file doesn't address this, probably because the functionality is there without a script. However, I have about 100 of these to configure and don't want to have to fill out that thing every time when they are all the same. I'd rather just browse for the script for each of them.
Can anyone help me out?
BTW, what ever happened to simple text scripts?
I'm no expert and I am just learning the scripting objects here but I did write this script to get the IOS versions off of Cisco 2900 and 2950 Switches, maybe you can change it to work for your routers as well?
It reads IP address from a text file called C:\oneIP.txt, connects to each one in the file and places the IOS information into anotehr text file called C:\IOS.txt, any switch it cannot connect to is located in another text file called C:\NoConnect.txt.
# $language = "VBScript"
# $interface = "1.0"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set FSO = CreateObject("scripting.filesystemobject")
Set Shell = CreateObject("WScript.Shell")
Set SwitchIP = FSO.opentextfile("C:\oneIP.txt", ForReading, False)
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objSc = crt.Screen
Set objD = crt.Dialog
Set objSe = crt.Session
Set objW = crt.Window
objsc.Synchronous = True
While Not SwitchIP.atEndOfStream
IP = SwitchIP.Readline()
' connect To host On port 23 (the default telnet port)
'On Error Resume Next
objse.Connect "/TELNET "&IP&" 23"
If ( objse.connected ) Then
objse.logfilename = "c:\crt.Log"
objSc.Send "sword" & vbCr
objsc.Send "sho ver | include IOS" & vbCr
SelectRow = objSc.CurrentRow - 1
IOSline = objSc.Get(SelectRow, 1, SelectRow, 132 )
Set IOSfile = FSO.OpenTextFile("C:\IOS.txt",ForAppending, True)
IOSFile.writeline IP & " " & IOSline
objSc.Synchronous = False
Set Tempfile = FSO.OpenTextFile("C:\NoConnect.txt",ForAppending, True)
TempFile.writeline "Could Not Connect to " & IP
|Display Modes||Rate This Thread|