View Single Post
Old 04-25-2012, 12:22 PM
bgagnon bgagnon is offline
VanDyke Technical Support
Join Date: Oct 2008
Posts: 4,524
Hi rainman,

Since you are using an older version of SecureCRT, you might want to check your upgrade eligibility here.

Are you already connected when you run the script?

If so, you would need to include a check for this condition in your script. The below version of the script illustrates this:

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

' Turn on synchronous mode while performing Send/Wait sequences
' so no input is missed.
crt.Screen.Synchronous = True

Sub Main

Dim vHosts(3)
vHosts(0) = ""
vHosts(1) = ""
vHosts(2) = ""

For Each strHost In vHosts
    If strHost = "" Then Exit For

    If crt.Session.Connected Then
        Loop While crt.Session.Connected
    End If

    crt.Session.Connect "/Telnet " & strHost
    crt.Screen.WaitForString "login: "
    crt.Screen.Send "username" & vbCr

    crt.Screen.WaitForString "Password: "
    crt.Screen.Send "pass1234!" & vbCr

    crt.Screen.WaitForString "> "
    crt.Screen.Send "Show ver" & vbCr

    crt.Screen.WaitForString "> "
    crt.Screen.Send "logout" & vbCr


' Turn off synchronous mode
crt.Screen.Synchronous = false

End Sub

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote