View Single Post
Old 04-24-2019, 09:46 AM
bwoo bwoo is offline
Registered User
Join Date: Apr 2019
Posts: 1
Question 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
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?
Reply With Quote