VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Saving/restoring log file name with variables (https://forums.vandyke.com/showthread.php?t=13515)

bwoo 04-24-2019 09:46 AM

Saving/restoring log file name with variables
 
I have a question about log files and scripts.

I routinely capture my SecureCRT sessions using a log file name with variables, e.g. "%Y_%M_%D %S.log"

I also have to occasionally run a script which captures a bunch of information in separate log files. This script fails when I run it because I already have a log file open.

I am rewriting the script so that it checks for an existing capture and, if there is one, it saves the current capture file name and closes it:
If crt.Session.Logging = True Then
bPreviousCapture = True
strPreviousCapture = crt.Session.LogFileName
crt.Session.Log False
Else
bPreviousCapture = False
End If
The original log file is restored at the end of the script:
If bPreviousCapture = True Then
crt.Session.LogFileName = strPreviousCapture
crt.Session.Log True, True
End If
Unfortunately, crt.Session.LogFileName returns the capture file name with the variables already populated, so once the script is finished my capture file name is fixed instead of variable.

Is there a way to save and restore the proper capture file name with the variables intact?

bgagnon 04-24-2019 10:03 AM

Hi bwoo,

Probably. I think you would just want to get at the data using SessionConfiguration object instead (before enabling logging).

What version of SecureCRT are you using?

The option associated with your log file info is Log Filename V2. See the info for GetOption() and SetOption() methods in the Help topic Scripting / Script Objects Reference / SessionConfiguration Object.


All times are GMT -6. The time now is 12:23 AM.