#1
|
||||
|
||||
Custom Log Data not working
I have a script that works very well to establish AdHoc connections to devices. This script has an added bonus of trying SSH, then TELNET. Once either of those is connected, I have code as follows (all variables are properly defined):
Code:
Select Case bConnected Case True ' Connected UserName = env("USERNAME") UserProf = env("USERPROFILE") objTab.Caption = strConnectType & strShortHostName crt.Session.SetStatusText("Connected: " & strConnectType & strShortHostName) Set objTab = crt.GetScriptTab Set objConfig = objTab.Session.Config objConfig.SetOption "Custom Log Message Each Line", "%h:%m:%s | " crt.Session.LogFileName = UserProf & "\SecureCRT Logs\" & UserName & "\%Y-%M-%D.%h.%m - " & strShortHostName & " -- (" & UserName & ").log" crt.Session.Log True Case False ' Not Connected crt.Dialog.MessageBox "Try again later:" & vbCrLf & strShortHostName End Select objConfig.SetOption "Custom Log Message Each Line", "%h:%m:%s | " I do get my log file in the specified folder, but the lines have no time stamp. I am using: Version 8.3.4 (x64 build 1699) - Official Release - July 12, 2018 and have no ability to upgrade. Last edited by Rhudi; 10-27-2020 at 10:30 AM. Reason: minor correction |
#2
|
|||
|
|||
Hi Rhudi,
You wrote that you are establishing ad hoc connections. Is that now in a new tab, that is not the script tab? Because within your Case statement you set the tab object to again be the script tab. Instead you would want to reference your new tab object, where the connection was established with ConnectInTab() I assume. ![]()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
||||
|
||||
There are numerous steps in this script that are unrelated to the logging. Basically, I am using a command line to pass arguments to a new tab. Once that tabs is running, it connects to a pre-defined session. That host is a Linux system. The next part of my script confirms the target host is valid by doing an nslookup on the name passed. That part works as expected. Still within the Linux host, I ssh to the target device (If that connection times out, it will try a telnet). I will get to the target device with no problem. My log file opens with no trouble. I just don't get the time stamp on each line.
I believe you have pointed me in the right direction. The script is running within the tab I've started. It may very well be that I'm not telling the right thing to log the time per line. |
#4
|
||||
|
||||
I believe I made an error by saying "AdHoc".
Strictly speaking, these are not AdHoc. I'm using an externally scripted shell command to launch a pre-defined Linux Host Session in SecureCRT. One of the command line arguments is my script. That will start SecureCRT if it is not running, or start a new tab if it is. That new tab is where my script is running. I have logging options set in the defined session, but they do not seem to work. Plus, I don't need any of the Linux part logged. I only want to log after the Linux has connected to the actual end device. I do get a log, I get it when I want. I just don't get the per-line time stamp I'd like to have. |
#5
|
|||
|
|||
Hi Rhudi,
I still cannot replicate your results. Are you sure you are going into the correct Case statement with the log each line configuration? Here were my steps which is a simplified version of what I understand your objective to be. My script is: Code:
Set objTab = crt.GetScriptTab Set objConfig = objTab.Session.Config objConfig.SetOption "Custom Log Message Each Line", "%h:%m:%s | " objTab.Session.LogFileName = "C:\Temp\Ubuntu_%Y-%M-%D.%h.%m.log"
12:52:16 | 13:52:16 up 17 days, 22:11, 2 users, load average: 0.06, 0.25, 0.20 12:52:17 | user@ubuntu:~$ pwd 12:52:17 | /home/vdt-csg I have tested this both in the official release and v8.3.4 and it works in both versions. You will need to post explicit steps and the entire script with sensitive data redacted or send it to support@vandyke.com with Attn Brenda - Forum Thread #14326 in the subject line.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#6
|
||||
|
||||
I deeply appreciate your time helping me with this.
Here is the relevant (I think) section: Code:
Select Case bConnected Case True ' Connected UserName = env("USERNAME") UserProf = env("USERPROFILE") objTab.Caption = strConnectType & strShortHostName crt.Session.SetStatusText("Connected: " & strConnectType & strShortHostName) Call CLS objTab.Session.Log False Set objConfig = objTab.Session.Config objConfig.SetOption "Custom Log Message Each Line", "%h:%m:%s | " objTab.Session.LogFileName = UserProf & "\SecureCRT Logs\" & UserName & "\%Y-%M-%D.%h.%m - " & strShortHostName & " -- (" & UserName & ").log" objTab.Session.Log True Case False ' Not Connected crt.Dialog.MessageBox "Try again later:" & vbCrLf & strShortHostName End Select Is "objTab.Session.Log True/False" the correct way to toggle logging? I did an experiment... I did what you did, using the File Menu to Toggle Logging. At that point, the lines are tagged as expected. So, the way I am trying to enable logging with the script is the culprit. Last edited by Rhudi; 10-27-2020 at 10:23 PM. Reason: Additional info |
#7
|
||||
|
||||
This fixes it:
objTab.Session.LogUsingSessionOptions Last edited by Rhudi; 10-28-2020 at 12:43 PM. Reason: SOLVED |
#8
|
|||
|
|||
Hi Rhudi,
I replied to your email. The answer is yes, because the change you apply with SetOption() changes Session Options for the session launched via command-line. That's the only way to apply the per line config options since there is not a command-line option for it.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#9
|
||||
|
||||
[SOLVED]
Here is the relevant section that now works as expected: Code:
Select Case bConnected Case True ' Connected UserName = env("USERNAME") UserProf = env("USERPROFILE") objTab.Caption = strConnectType & strShortHostName objTab.Session.SetStatusText("Connected: " & strConnectType & strShortHostName) Call CLS objTab.Session.Log False objTab.Session.Config.SetOption "Custom Log Message Each Line", "%h:%m:%s | " objTab.Session.LogFileName = UserProf & "\SecureCRT Logs\" & UserName & "\%Y-%M-%D.%h.%m - " & strShortHostName & " -- (" & UserName & ").log" objTab.Session.LogUsingSessionOptions Case False ' Not Connected crt.Dialog.MessageBox "Try again later:" & vbCrLf & strShortHostName End Select Code:
objTab.Session.LogUsingSessionOptions |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|