Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-11-2009, 03:21 PM
1720 1720 is offline
Registered User
Join Date: Jul 2007
Posts: 13
Multiple methods of connecting to device

I am trying to use SecureCRT to connect to a device first trying ssh and if it fails, then use telnet. The script runs fine if the device supports ssh, but if it does not and only supports ssh, I am getting a Runtime error. Here is my 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 ", passwd, "TACACS Password",True)

cmd = "/SSH2 /L " & user_name & " /PASSWORD " & passwd & " " & device

crt.Session.Connect cmd

if crt.Screen.WaitForString(device, 4) = True then
crt.window.caption = device
' crt.Screen.Send passwd & vbCr
crt.Screen.Send "telnet " & device & chr(13)
crt.Screen.WaitForString "Username:"
crt.Screen.Send user_name & vbCr
crt.Screen.WaitForString "Password:"
crt.Screen.Send passwd & vbCr
end if
End Sub
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 08:12 AM.