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 01-08-2021, 07:58 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 137
Exit Script without error popup

Hi,

My ultimate goal is to monitor the SSH session for a defined string and then create a dialog and send text when that string is found.

This I can do, but it gives an error whenever the SSH connection is lost. I want to suppress popup error and just exit the script.

I am starting the scrip using the Logon script option under Connection->Logon Actions.

The relevant part of the script looks like this:

Code:
crt.Screen.Synchronous = True
Sub Main
	'handle the login details here

	crt.Screen.Synchronous = False
	Do while 1
		If crt.Screen.WaitForString ("Explict Text") = True Then
			Result = crt.Dialog.Prompt("Enter a value", "Enter Value")
			If Result = "" Then exit sub
			'send the results here
		End If
	Loop
End Sub
I've tried playing On Error, but can't seem to get it to work for me.

Are you aware of another way to implement this functionality or to suppress the Connection Lost Error?

Currently running 8.2.0.

Thanks,

Wes
Reply With Quote
  #2  
Old 01-08-2021, 08:26 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 137
As usual, as soon as I post a question, I get it to work. Here is the relevant change. I added both the Error Resume Next and the two Session.Connected checks.

Code:
	Do while 1
		On Error resume next
		If crt.Session.Connected = 0 then
			exit sub
		End If
		If text.WaitForString ("Explict Text") = True Then
			If crt.Session.Connected then
				Result = crt.Dialog.Prompt("Enter a value", "Enter Value")
				If Result = "" Then exit sub
				'send the results here
			else
				Exit Sub
			End if
		End If
	Loop
End Sub
Reply With Quote
  #3  
Old 01-08-2021, 09:23 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,596
Hi WesR,

Thanks for posting the solution. I am glad you were able to resolve the issue.
__________________
Thanks,
--Brenda

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


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 07:01 PM.