View Single Post
  #4  
Old 02-12-2009, 06:11 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
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?
Attached Files
File Type: txt ConnectionProtocolFallback-PromptForTarget.txt (8.6 KB, 278 views)
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote