Hi,
Thanks for confirming that you're wanting to use a protocol fallback. The current problem looks like it's coming as a result of not being able to connect using SSH2. If you were to trap the error (On Error Resume Next) then this may not happen and the script should continue. However, there would still be the issue of trying to connect to a telnet server using Crt.Screen.Send.
I ran some tests and modified your code slightly. In my tests the script seemed to work as I think you're wanting. The modified code is below.
Code:
# $language = "VBScript"
# $interface = "1.0"
Sub Main
crt.Screen.Synchronous = TRUE
Dim prompt
prompt = "Password: "
Dim device
device = crt.Arguments(0)
Dim user_name
user_name = crt.Dialog.Prompt("Enter your TACACS userID ", user_name, "TACACS Login",False)
Dim passwd
passwd = crt.Dialog.Prompt("Enter your TACACS Password ",
cmd = "/SSH2 /L " & user_name & " /PASSWORD " & passwd & " " & device
' Prevent an error from stopping script execution
On Error Resume Next
crt.Session.Connect cmd
if crt.Screen.WaitForString(device, 1) <> True then
cmd = "/TELNET " & device
crt.Session.Connect cmd
crt.Screen.WaitForString "Username:"
crt.Screen.Send user_name & vbCr
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbCr
else
crt.window.caption = device
end if
End Sub
I'm also attaching a script which you might be interested in looking through. It uses telnet to determine whether or not there is an SSH server (if telnet server port 22 returns a response, that's an SSH server). I think it's a pretty robust script and you might find some useful code in it.
Does the modified script above work any better for you?
Do you think you might be able to modify the ConnectionProtocolFallback-PromptForTarget script to work for your particular goal?