#1
|
|||
|
|||
How to suppress connection lost error dialog
If a crt loses connection while a script is running (specifically during a WaitForKey), I get a pop up dialog that says:
CRT Scripting Runtime error Error: Connection lost File: C:\someplace\somewhere\blahblah.vbs Line 17 Is there a way to suppress that error dialog? |
#2
|
|||
|
|||
Well, the good news is I found if I just use On Error Resume Next and a check for being connected, it suppresses the error dialog. I'll post the script below. Please ignore the other actions taken... they're not relevant to my question. The script works fine, but there is one artifact that tells me I have something wrong. The script runs indefinitely, through logins and log offs. At login, the server banner message seems to scroll across the screen, behind the login dialog, like I was on a 300 baud modem. It doesn't seem to effect my ability to login, but it is evidence that something isn't quite right.
Here's the script so far... Code:
#$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True Sub Main On Error Resume Next Do If crt.Session.Connected Then Active else Inactive End If Loop End Sub Sub Active On Error Resume Next Dim result Dim snip Do result = crt.Screen.WaitForKey(300) If not crt.Session.Connected Then Exit Do End If If result = 0 Then snip = crt.Screen.Get(crt.Screen.Rows,1,crt.Screen.Rows,5) If snip = "SQL> " Then crt.Screen.Send "EXIT;" & chr(13) End If End If Loop End Sub Sub Inactive On Error Resume Next Do crt.Sleep 5000 If crt.Session.Connected Then Exit Do End If Loop End Sub Darren |
#3
|
|||
|
|||
Hi Darren,
Quote:
By the way, what version of SecureCRT are you using?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#4
|
|||
|
|||
Correct. If the script is not running, the server banner pops up almost instantly. But with the script running, I can actually see the banner slowly printing out at about 15 characters per second behind the login dialog--probably takes abou 10 full seconds to display the whole banner. If I complete my login before the entire banner has displayed, it then finishes instantly.
I put some MsgBox commands around the script and discovered that the Sleep command does not appear to be executing. It is must be generating an error, and since I have On Error Resume Next, it exits the Do...Loop. Does Sleep only work while connected? I removed the Sleep and now the execution stays in that Do...Loop, but it didn't fix the slow down of the banner display. At this point, it appears to be just cosmetic, but it's always nice to know why something is happening. |
#5
|
|||
|
|||
Hi Darren,
Quote:
Quote:
How are you authenticating? How are you running the script? What are you hoping to accomplish with this line? Quote:
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by bgagnon; 10-10-2016 at 11:53 AM. |
![]() |
Tags |
connection lost , disconnect , runtime error , suppress |
Thread Tools | |
Display Modes | Rate This Thread |
|
|