|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
![]()
I have been trying to write a script that examines the software type on various routers and have come across a discrepancy in expected behaviour between telnet and SSH connections. The synchronous property does not seem to have an affect on SSH sessions while it does for telnet sessions. The stranger part of this problem is that I am using a jump server so I would have expected SecureCRT to be agnostic as to what protocol is being used.
I have enabled Synchronous as true on the screen object. I have thoroughly read through the published scripting guide, which even mentions SSH as part of the example. Here is a cut-down version of the script I'm using the exhibits the behaviour I'm describing: Code:
Sub Main() Dim objTab Dim UID Dim Router Dim protocol Dim Password Router = "router" protocol = "SSH" Password = "password" UID = "user" Set objTab = crt.GetScriptTab objTab.Screen.Synchronous = True vPossiblePrompts = Array(_ Router + "#",_ Router + "-re0>",_ Router + "-re1>") Select Case protocol Case "Telnet" cnxnString = "telnet " & Router Case "SSH" cnxnString = "ssh " & "-P " & Password & " " & UID & "@" & Router End Select objTab.Screen.Send cnxnString & chr(13) If protocol = "Telnet" then objTab.Screen.WaitForStrings "sername:","ogin:" objTab.Screen.Send UID & chr(13) objTab.Screen.WaitForString "assword:" objTab.Screen.Send Password & chr(13) End If objTab.Screen.WaitForStrings vPossiblePrompts objTab.Screen.Send "sh ver " + chr(124) + " i Cisco.*[I-]OS" + chr(13) objTab.Screen.WaitForStrings vPossiblePrompts screenrow = objTab.Screen.CurrentRow screenrow = screenrow - 1 tempDevice = objTab.Screen.Get(screenrow, 1, screenrow, 80 ) DeviceType = "undefinied" If instr(tempDevice,"IOS") > 0 then DeviceType = "IOS" End If If instr(tempDevice,"IOS-XE") > 0 then DeviceType = "IOS-XE" End If If instr(tempDevice,"Nexus") > 0 then DeviceType = "NX-OS" End If MsgBox "tempDevice is " & tempDevice MsgBox "DeviceType is " & DeviceType objTab.Screen.Send "exit" & chr(13) End Sub When connecting using the Telnet protocol everything works as expected. When using SSH the 'tempDevice' variable returns with the line directly above the command prompt immediately after logging in to the device. I have checked the output difference between telnet and SSH and the SSH output contains no unexpected matches within the "vPossiblePrompts" variable that could be causing the WaitForStrings to continue unexpectedly. When the message boxes are dismissed the commands run as expected. The output of the SSH session is as follows: Quote:
SecureCRT 7.2.3 build 500 Windows 7 Thanks in advance |
Tags |
scripting , ssh , synchronous |
Thread Tools | |
Display Modes | Rate This Thread |
|
|