#1
|
|||
|
|||
Log Session doesn't prompt for file name any more
Hi all. I created the code below to check if logging is currently turned on so I could give a user a choice of options instead of cutting off their log against their wishes. But after running this script I've discovered that if I go to File -> Log Session to manually start a new log I'm no longer asked where I want the file to be saved or what I want the log to be named, it automatically uses the time stamp below and hostname discovered on the last run of the script. Is there any way to stop this? I want to be able to record other logs and manually choose their names and locations outside of the situation where I would be running this script.
Code:
sub Main crt.Screen.Synchronous = True ' If folder doesn't exist create it ' Dim filesys, newfolder set filesys=CreateObject("Scripting.FileSystemObject") If Not filesys.FolderExists("C:\00 - SecureCRT Logfiles") Then newfolder = filesys.CreateFolder ("C:\00 - SecureCRT Logfiles") End If ' Check to see if logging is enabled ' If crt.Session.Logging <> False Then Result = MsgBox ("Session logging is already enabled." & vbcr & vbcr & "Click 'YES' to use your current log." & vbcr & "Click 'NO' to end the current log and create a new one for this script." & vbcr & "Click 'CANCEL' to terminate this script without doing anything.", _ vbYesNoCancel + vbExclamation + vbDefaultButton3 + vbApplicationModal + vbMsgBoxSetForeground, _ "Session Logging Decision Needed") If Result = vbYes Then crt.Sleep 1000 End If If Result = vbNo Then Call StartLog End If If Result = vbCancel Then Exit Sub End If Else Call StartLog End If ' ' body of script here ' End Sub Sub StartLog ' Get hostname to be used in the logfile filename ' crt.Screen.Send "show system" & vbCr : crt.Screen.WaitForString vbCr strHNPre = crt.Screen.ReadString ("#") strHN = Split(Mid(strHNPre, 32), vbcrlf)(0) ' Set logfile name & turn on logging ' logfile = "C:\00 - SecureCRT Logfiles\%Y.%M.%D-%h.%m.%s-" & strHN & ".log" ' msgbox "logfile name will be " & MyDate & "-" & strHN & ".log" crt.Session.LogFileName = logfile crt.Session.Log False crt.Session.Log True End Sub |
#2
|
|||
|
|||
Hi emailsbecker,
When you choose File / Log Session, if the Terminal / Log File category of SecureCRT's Session Options is configured with a valid log path, it will be used unless the Prompt for filename option is enabled However, the user will always be prompted for a log file name if the session option Log file name is blank. This line in your code changes Session Options so that the log file name is no longer blank: Code:
crt.Session.LogFileName = logfile This has the added benefit that if the user does already have a custom log file name, running your script will not wipe out their configuration. Code:
strOrigLogFilename = crt.Session.Config.GetOption("Log Filename") crt.Session.LogFileName = logfile crt.Session.Log False crt.Session.Log True crt.Session.Config.SetOption "Log Filename", strOrigLogFilename
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi Brenda,
I'm using 6.1.1 (build 383) and it worked for me. Thanks! ~Steve |
#4
|
|||
|
|||
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|