#1
|
|||
|
|||
Logging Filename; port variable?
Hello-
I frequently connect to multiple devices via a comm server and I would like to log the devices to individual files automatically. The comm server uses unique port numbers to differentiate which device is being connected to. So telnet://comm-server:2000 is router1 and telnet://comm-server:2001 is switchB, whatever. Anyway, in the logging panel I can set the filename such as: d:\data\logs\%Y%M%D-%H.log but that means all the devices want to log to "{date}-comm-server.log" Is there a way to specify the port that the connection was made to so that I can uniquely identify the machines? Such as: d:\data\logs\%Y%M%D-%H-%P.log so it will generate "{date}-comm-server-2000.log" Using SecureCRT v6.7.4 (build 354) WinXP Thanks. -gregg |
#2
|
|||
|
|||
Oh, I'm not using %S (session name) because 99% of the time I connect from a wiki page with "a href=telnet://" tags.
|
#3
|
|||
|
|||
Hello gregg,
There is not a substitution variable (%P) currently available that can accomplish your objective, but I believe you could use a script to do so. I have attached an example script that illustrates how you can log to a different file based on the remote's IP address. There is a similar property (RemotePort) that returns the port number of the remote port. (See the SecureCRT Help topic Scripting / Script Objects Reference / Session Object for additional information.) So, on line 52 of the example script, you might change the log file template to be similar to below: Code:
g_strLogFileNameFormat = "YEAR-MONTH-DAY--REMOTE_IP_ADDRESS--PORT" Code:
strNewFilename = Replace(strNewFilename, "REMOTE_IP_ADDRESS", crt.Session.RemoteAddress) strNewFilename = Replace(strNewFilename, "MONTH", NN(Month(strCurrentTime))) strNewFilename = Replace(strNewFilename, "YEAR", NN(Year(strCurrentTime))) strNewFilename = Replace(strNewFilename, "DAY", NN(Day(strCurrentTime))) strNewFilename = Replace(strNewFilename, "PORT", crt.Session.RemotePort) Using the above information and the attached example script, are you able to log to separate files with the filenames desired?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#4
|
|||
|
|||
Thanks! It does work. I mucked with it a little bit so I could apply it across all of my sessions as well (so if there is a session name, it uses that instead):
Code:
strSessionPath = crt.Session.Path strSessionName = g_fso.GetFileName(strSessionPath) If strSessionName = "Default" Then strNewFilename = Replace(strNewFilename, "REMOTE_IP_ADDRESS", crt.Session.RemoteAddress) strNewFilename = Replace(strNewFilename, "PORT", crt.Session.RemotePort) Else strNewFilename = Replace(strNewFilename, "REMOTE_IP_ADDRESS", strSessionName ) strNewFilename = Replace(strNewFilename, "-PORT", "") End If |
#5
|
|||
|
|||
Hi gregg,
Excellent, I am glad to hear the example script was helpful. Thanks for posting the changes here. ![]() As a note, I have added this thread to a feature request in our product enhancement database to add a new substitution variable for logging (%P for port). Should a future release of SecureCRT include this feature, notification will be posted here. If you prefer direct e-mail notification, contact support@vandyke.com and include "Feature Request - Forum Thread #10506" in the subject line.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by bgagnon; 06-05-2012 at 09:26 AM. Reason: Added feature request text |
#6
|
||||
|
||||
Quote:
Maureen |
![]() |
Thread Tools | |
Display Modes | |
|
|