#1
|
|||
|
|||
Error handler for failure to turn logging on
Is there a way to handle an error that occurs when turning on logging with an illegal filename?
I am having an error in a script when it turns on logging. I want to work out a way to handle the error. I tried checking if crt.GetScriptTab().Session.Log(True) returns a value but it does not seem to. Thanks as always for any reply Script fragment is below Code:
LogFileStrNew = dirname + "\%Y-%M-%D %hh%mm%ss %S " + CommandStr + ".log" writeB("00520 LogFileStrNew :" + LogFileStrNew) crt.Session.Config.SetOption("Log Filename", LogFileStrNew) LogReturn = 0 writeB("00525 LogReturn Initialised :" + str(LogReturn)) LogReturn = crt.GetScriptTab().Session.Log(True) writeB("00527 LogReturn Return :" + str(LogReturn)) |
#2
|
|||
|
|||
Hi slouw,
This is more of a Python question than SecureCRT. You can typically use try/except blocks for error handling in Python. Or, you might use existing script code Jake has in several example scripts to "clean up filenames". This block is from the RunCommandsOnMultipleHostsAndLogResults example. Code:
# Replace any illegal characters that might have been # introduced by the command we're running (e.g. if the # command had a path or a pipe in it) strCleanCmd = strCommand.replace('/', "[SLASH]") strCleanCmd = strCleanCmd.replace('\\', "[BKSLASH]") strCleanCmd = strCleanCmd.replace(':', "[COLON]") strCleanCmd = strCleanCmd.replace( '*', "[STAR]") strCleanCmd = strCleanCmd.replace( '?', "[QUESTION]") strCleanCmd = strCleanCmd.replace( '"', "[QUOTE]") strCleanCmd = strCleanCmd.replace( '<', "[LT]") strCleanCmd = strCleanCmd.replace( '>', "[GT]") strCleanCmd = strCleanCmd.replace( '|', "[PIPE]") strLogFile = strLogFile.replace("COMMAND", strCleanCmd)
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Appreciate reply thank you Brenda
Line 524 on this file RunCommandsOnMultipleHostsAndLogResults.py.txt Has this line (extra backslash added to try and make [QUOTE] part of code. Failed.... ![]() Quote:
|
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|