View Single Post
Old 05-08-2019, 08:27 AM
bgagnon bgagnon is offline
VanDyke Technical Support
Join Date: Oct 2008
Posts: 4,636
Hi christopherchiu,
In SecureCRT, i have a script that display 2 dialog boxes for inputs. i want to exit out when either (a) user hit <cancel>, or (b) user hit <ok> but nothing was entered.
There's an example in the SecureCRT Help topic for Dialog Object / Prompt Method (Scripting / Script Objects Reference):

crt.Dialog.Prompt(message [, title [, default [, isPassword ]]])
password = crt.Dialog.Prompt("Enter your password:", "Logon Script", "", True)
if password == "":
# User clicked Cancel button
# User added data
The if == "" would cover both a cancel or empty scenario. To exit out, use return or break.

When in VB, there is a system variable Err.Number. How is it in python? Thanks
As I told you in email, I don't know that there is a direct equivalent. If you wrap code in a try/except block there are built-in exceptions available in Python but that's more a Python inquiry than it is SecureCRT.

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote