VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Help with AutoResponder Script (https://forums.vandyke.com/showthread.php?t=12704)

ofmanyone 05-17-2017 12:02 PM

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

ekoranyi 05-17-2017 02:46 PM

Hi ofmanyone,

I don't know that using that particular example script is the best option for your usage. It would help me better understand the requirements if you could provide a log file demonstrating you accomplishing this manually. We prefer to keep logs out of the forums to reduce the risk of accidentally exposing sensitive data. Could you take the below steps to generate a log and email it to Support@VanDyke.com with "Attn: Eric forum post 12704" in the subject.
  • Launch SecureCRT and open SecureCRT's main "File" menu and choose "Log Session..."
  • Specify a path to your Desktop folder and a name of the log file, such as SCRT_Log.txt.
  • Connect to the terminal server and a device.
  • Once you've demonstrated the login procedure disconnect from the session.
  • Go to your Desktop folder and locate the SCRT_Log.txt file. Please send the SCRT_Log.txt file to me as an attachment to your reply. Please don't paste the contents into the body of your message -- please attach it!


All times are GMT -6. The time now is 10:12 PM.