View Single Post
  #10  
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:

Code:
#$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) = "10.1.1.1"
vHosts(1) = "10.1.1.2"
vHosts(2) = "10.1.1.3"

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

    If crt.Session.Connected Then
        Do 
            crt.Session.Disconnect
            crt.Sleep(25)
        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

Next

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

End Sub
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote