View Single Post
  #8  
Old 02-18-2009, 04:00 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Quote:
(1) When the device connects via ssh, it connects fine but then for some reason it issues a telnet to the same device
I think this could be due to timing. You might try increasing the WaitForString timeout to 5 seconds. Rather than waiting for a string,
what happens if you use Crt.Session.Connected instead of Crt.Screen.WaitForString?

Quote:
[(2) If the device supports only telnet, it is not connecting now. Not sure why.
I am attaching the script.
It looks like you reverted your code to much the same code you originally had.

Your code for the else statement is trying to send a string to a session that is not connected, which is the problem.

Here is the problematic snippet of the code:
Code:
else
    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
Using Crt.Screen.Send when SecureCRT is not connected causes the CRT Scripting Runtime error you saw before: "Error: Screen.Send: not connected". On Error Resume Next is hiding this error from you, but it's still an error.

Since you're not connected you cannot send a string to the screen.

Use a variable to build the command and use Crt.Session.Connect, instead of using Crt.Screen.Send.
Code:
    cmd = "/TELNET " & device
    crt.Session.Connect cmd
Does the following code snippet work better for you?
Code:
if crt.Screen.Connected = True then
    crt.window.caption = device
else
    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
end if
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote