Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 04-26-2019, 11:37 AM
krypton179 krypton179 is offline
Registered User
Join Date: Apr 2019
Posts: 3
Existing Script from Within Function

Hi Experts,

I am looking for some further details of how I can exit an active script from within a function without logging the script path and line number.

Looking at earlier threads I found this logic, which works:

def CancelScript()

However, instead of opening a dialog box, I would like to exit the script without printing anything to the screen.

I looked into using the crt.Quit() option, but this closes CRT completely.

Are there any alternatives which I can use to accomplish this?

Kind Regards,

Reply With Quote
Old 04-26-2019, 12:44 PM
jpellegrini jpellegrini is offline
Registered User
Join Date: Mar 2019
Posts: 20
Hi krypton179,

Unfortunately, there is currently not a way to disable the "Script Cancelled" dialog when a script is cancelled.

However, I have added this thread to a feature request in our product enhancement database for an option to disable the "Script Cancelled" dialog. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #13517" in the subject line or use this form from the support page of our website.

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote
Old 06-07-2019, 01:57 PM
gregg gregg is offline
Registered User
Join Date: Oct 2010
Posts: 75
use try/except

sys.exit(0) causes an error, but you can raise an Exception to abort a function up to a try/except block and then do nothing with the exception.


# $language = "Python"
# $interface = "1.0"

# By having a specific exception to look for,
# other exceptions won't be ignored.
class EarlyExit(Exception):

def func2():
    crt.Dialog.MessageBox("About to exit script early", "Bye")
    raise EarlyExit()

def func1():

def main():
        crt.Dialog.MessageBox("Should not see this", "Wut")
    except EarlyExit:

Reply With Quote


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 11:35 PM.