View Single Post
  #1  
Old 05-17-2017, 12:02 PM
ofmanyone ofmanyone is offline
Registered User
 
Join Date: Jul 2013
Posts: 3
Help with AutoResponder Script

Hi. I'm trying to use an AutoResponder script for reverse telnet console connections. I'm not a programmer, just a network engineer. I used the sample script that came with the software.

Scenario: I reverse telnet to a device from a Cisco IOS terminal server in order to gain console access. First, I am prompted for the user/pass of the terminal server. Next, I am prompted for the user/pass of the console device. Sometimes I get an "unprivileged" prompt such as "hostname>", in which case I want to type "enable", then the enable password. Sometimes, there is no device connected to the console cable and the session hangs after the initial authentication. In that case, when the cursor doesn't move for 3 seconds, I want to send the abort sequence "CTRL+SHIFT+6", "X". I also want the script to exit in such a case. Here is my script, which I have tweaked many times with no success. Right now, it won't send the abort sequence if the session hangs. I welcome your thoughts and ideas.

#$language = "VBScript"
#$interface = "1.0"

g_vWaitFors = Array("username:", _
"password:", _
">")

g_vRespondWiths = Array("username", _
"password", _
"en")

Sub Main()
Set objTab = crt.GetScriptTab
bCursorMoved = crt.Screen.WaitForCursor(3)

If objTab.Session.Connected <> True then
crt.Dialog.MessageBox _
"Error." & vbcrlf & _
"This script was designed to be launched after a valid " & _
"connection is established." & vbcrlf & vbcrlf & _
"Please connect to a remote machine before running this script."
Exit Sub
end if
If bCursorMoved = True then
Do
Loop Until bCursorMoved = False
objTab.Screen.Synchronous = true
nIndex = objTab.Screen.WaitForStrings(g_vWaitFors)
objTab.Screen.Send g_vRespondWiths(nIndex - 1) & vbcr
Do
Loop
crt.Screen.Send chr(30) & "x"
crt.Screen.WaitForString "#"
crt.Screen.Send "disc" & chr(13)
crt.Screen.WaitForString "[confirm]"
crt.Screen.Send chr(13)
Exit Sub
End If
End Sub
Reply With Quote