VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Exit Script without error popup (https://forums.vandyke.com/showthread.php?t=14388)

WesR 01-08-2021 07:58 AM

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

WesR 01-08-2021 08:26 AM

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


bgagnon 01-08-2021 09:23 AM

Hi WesR,

Thanks for posting the solution. I am glad you were able to resolve the issue. :)


All times are GMT -6. The time now is 04:27 PM.