|
![]() |
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
Error when running "Import Arbitrary Data From File to SecureCRT Sessions" script
I have recently upgraded to SecureCRT Version 9.0.1 (build 2451)
I am running it on macOS Catalina: 10.15.7 (19H524) and when trying to run the: "Import Arbitrary Data From File to SecureCRT Sessions" script from the Script Examples post; I get the following error: Code:
SyntaxError Error: invalid syntax File: /Volumes/GoogleDrive/My Drive/SecureCRT_Scripts/ImportArbitraryDataFromFileToSecureCRTSessions.py Line: 443 except Exception, objErr: Code:
def OpenPathInDefaultApp(strFile): strPlatform = sys.platform crt.Session.SetStatusText("Platform: {0}".format(strPlatform)) crt.Sleep(200) try: if sys.platform.startswith('darwin'): subprocess.call(('open', strFile)) elif strPlatform == "win32": os.startfile(strFile) elif sys.platform.startswith('linux'): subprocess.call(('xdg-open', strFile)) else: MsgBox("Unknown operating system: " + os.name) ##Line 443->>## except Exception, objErr: MsgBox( "Failed to open " + strFile + " with the default app.\n\n" + str(objErr).replace('\\\\', '\\').replace('u\'', '\'')) |
#2
|
||||
|
||||
That example script is written for Python 2.7 which is no longer supported in SecureCRT 9.0 and newer versions on the macOS platform.
Changing that line from... except Exception, objErr:...to: except Exception as objErr:... would certainly help. Another change you'll likely need to make is on the line near line #461, so that instead of a <> on that line... if g_strErrors <> "":...you should have a != instead: if g_strErrors != "":There may very well be other changes needed to the script example you're trying to use in order for it to work with Python 3. When cycles become available for us to provide a python 3 version of the script, we'll update that post. --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
#3
|
||||
|
||||
Thanks for pointing me in the right direction.
After a little searching I found the 2to3 tool included in Python and ran it against the script. It went through and updated the syntax to work with Python3. Afterwards I was able to successfully import the sessions to SecureCRT 9.0.1 I'd be happy to send you the updated script if you want. |
#4
|
||||
|
||||
Quote:
Sure, send it! Either attach the file to a post in this forum thread, or send it to support@vandyke.com referencing forum thread #14473 in the subject of your email message. --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
#5
|
||||
|
||||
I have attached a copy of the updated file.
I had to append the extension ".txt" to allow it to be attached to my post. I hopes this helps others. |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|