Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-07-2016, 09:57 AM
sir_argo sir_argo is offline
Registered User
 
Join Date: Oct 2016
Posts: 3
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?
Reply With Quote
  #2  
Old 10-07-2016, 10:47 AM
sir_argo sir_argo is offline
Registered User
 
Join Date: Oct 2016
Posts: 3
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
So the only question I have now is, why does the server banner slow down to a crawl behind the login dialog while this script is running?

Darren
Reply With Quote
  #3  
Old 10-07-2016, 11:20 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Darren,

Quote:
So the only question I have now is, why does the server banner slow down to a crawl behind the login dialog while this script is running?
So are you saying that would not occur if doing these tasks manually, without the script (through logins and log offs)?

By the way, what version of SecureCRT are you using?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #4  
Old 10-07-2016, 01:19 PM
sir_argo sir_argo is offline
Registered User
 
Join Date: Oct 2016
Posts: 3
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.
Reply With Quote
  #5  
Old 10-10-2016, 10:10 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Darren,

Quote:
Does Sleep only work while connected?
No, it is just a pause in the execution of the script. Whether a valid connection exists or not has no bearing.


Quote:
If I complete my login before the entire banner has displayed, it then finishes instantly.
What protocol are you using to connect?

How are you authenticating?

How are you running the script?

What are you hoping to accomplish with this line?

Quote:
result = crt.Screen.WaitForKey(300)
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 10-10-2016 at 11:53 AM.
Reply With Quote
Reply

Tags
connection lost , disconnect , runtime error , suppress


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 10:26 PM.