#1
|
|||
|
|||
![]()
The script I've posted below goes thru a text file to get teh IOS versions off of multiple Switches. It all works except getting the Rows and Columns to display(IOS = objsc.Get(Row1, col1, Row2, col2)
I would like to be able to find Just the line that has the IOS on the screen to output to an excel spread sheet but I can get the code to work. Can someone help? 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" objse.Log(True),True objSc.WaitForString "assword:" objSc.Send "cisco" & vbCr wrongstr = objsc.WaitForString(">",1) 'objD.Messagebox "Wrongstr st To " & wrongstr If wrongstr = -1 Then objsc.WaitForString">",1 objsc.Send "sho ver | include IOS" & vbCr objsc.WaitForString">",1 IOS = objsc.Get(Row1, col1, Row2, col2) 'If InStr(IOS,"Software") Then objD.Messagebox objsc.Get(Row1, col1, Row2, col2) objse.Log(False) objSc.Synchronous = False objSE.Disconnect Else objsc.WaitForString">",1 objsc.Send "show version" & vbCr objsc.WaitForString">",1 objse.Log(False) objSc.Synchronous = False objSE.Disconnect End If Else Set Tempfile = FSO.OpenTextFile("C:\output.txt",ForAppending, True) TempFile.writeline "Could Not Connect to " & IP TempFile.Close() End If Wend |
#2
|
|||
|
|||
Just need to specify what row and columns
Where you have IOS = objsc.Get(Row1, col1, Row2, col2), when you issued the show version command it displays one line up from where your cursor ends up being. Therefore using something like
SelectRow = crt.Screen.CurrentRow - 1 IOSline = crt.Screen.Get(SelectRow, 1, SelectRow, crt.Screen.CurrentColumn ) Will give you the entire line containing the IOS. Now all you need to do is do a VB set of string finds and you can chop out the exteranous stuff to get down to the version. |
#3
|
|||
|
|||
That was it Thanks!!
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|