#1
|
|||
|
|||
GetOption, syntax
BackGround:
My logfilename has the following format: %Y-%M-%D %hh%mm%ss Hostname.log I am trying to stop logging, start a new log file with my existing Log file name but appending a string TempStr to the new logfilename. Effectively thus: %Y-%M-%D %hh%mm%ss Hostname TempStr.log Q1 It seemd the way to go here is to use the GetOption Method of the SessionConfiguration object. I see one relevant post here: http://forums.vandyke.com/showthread...ight=GetOption Q1 = Is this indeed the way to go or not? Q2: In regards to the GetOption Method of the SessionConfiguration object I could replicate retrieving the "Hostname" field from the Session Options as described in the post above. I could not retrive any other parameter though, for instance the Port parameter, or the Name parameter. So these would work: Crt.Dialog.MessageBox("Hostname1 is: " & Crt.GetScriptTab.Session.Config.GetOption("Hostname")) Crt.Dialog.MessageBox("Hostname2 is: " & crt.Session.Config.GetOption("Hostname")) But these would not: Crt.Dialog.MessageBox("Hostname1 is: " & Crt.GetScriptTab.Session.Config.GetOption("Name")) Crt.Dialog.MessageBox("Hostname2 is: " & crt.Session.Config.GetOption("Name")) Crt.Dialog.MessageBox("Hostname1 is: " & Crt.GetScriptTab.Session.Config.GetOption("Port")) Crt.Dialog.MessageBox("Hostname2 is: " & crt.Session.Config.GetOption("Port")) Crt.Dialog.MessageBox("Hostname1 is: " & Crt.GetScriptTab.Session.Config.GetOption(Port)) Crt.Dialog.MessageBox("Hostname2 is: " & crt.Session.Config.GetOption(Port)) Q2 = Why would "hostname" work but not the others? Q3 In relation to how the GetOption method should be referenced. GetOption method is a child of the SessionConfigurationObject. The syntax for the SessionConfiguration object says "SessionConfiguration.Method([arglist])" But neither of the 2 the syntax (What is plural for syntax?) which worked above appear to use this syntax. I have assumed from the help the following: - There is a tree structure with a text and dot notation to reference entities e.g. Node0.Node1.Node2....NodeN - Node0 is called the root; - The root for all SecureCRT scripting is "Crt" - All nodes with children (i.e. all but the last node, NodeN) are known as "Objects" - All leaf entities (last node on the tree) are either "Properties" or "Methods"; - Some "Properties" or "Methods" are "Objects" themselves (ie they have children); Q3 = Any comment about GetOption referencing or comment/recommened reading etc about syntax appreciated. |
#2
|
|||
|
|||
Ok I have made some progress
Q2:I have looked in the .ini file for the session I am working on. Immediately the distinction between String type (S) and DWORD type (D) is appearant. This works a treat: LogFileStr = Crt.Session.Config.GetOption("Log Filename") Still appreciate any comments on Q1 and Q3.... |
#3
|
||||
|
||||
Hi slouw,
Regarding your first question, there are a couple of ways you change the log file name. Here is a short script showing how you might do it using GetOption and SetOption. Code:
#$Language="VBScript" #$Interface="1.0" Sub Main szHostname = crt.session.config.getoption("Hostname") szLogFilename = crt.Session.Config.Getoption("Log Filename") Crt.Session.Log false szTempStr = "TempString" szNewLogFilename = Replace(szLogFilename, ".log", "") szNewLogFilename = szNewLogFilename & " " & szTempStr & ".log" crt.Session.Config.Setoption "Log Filename", szNewLogFilename crt.Session.Log true, true End Sub I've also attached a more robust VBScript which shows another way of setting the log filename. Regarding your question about syntax and tips on reading the syntax, I believe your comments about the syntax are correct. I tend to learn more about a language by looking at the syntax briefly then finding an example to play with extensively (testing out the methods and properties, etc.). So, my comment or tip about recommended reading is look for an example in the Help or in the forums and see what else you can do with it. ![]() Does anybody else have comments, tips, insights or recommended reading that may help?
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|