Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2012, 11:11 AM
gregg gregg is offline
Registered User
 
Join Date: Oct 2010
Posts: 75
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
Reply With Quote
  #2  
Old 06-04-2012, 12:17 PM
gregg gregg is offline
Registered User
 
Join Date: Oct 2010
Posts: 75
Oh, I'm not using %S (session name) because 99% of the time I connect from a wiki page with "a href=telnet://" tags.
Reply With Quote
  #3  
Old 06-04-2012, 12:54 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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"
Then the helper function beginning on line 96 would only need to include those five pieces of information you wish to include in the log filename (replacing lines 106 to 113, inclusive):

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)
The necessary configuration in SecureCRT (via Global Options / General / Default Session) is documented in the beginning of the example script.

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
Reply With Quote
  #4  
Old 06-04-2012, 05:50 PM
gregg gregg is offline
Registered User
 
Join Date: Oct 2010
Posts: 75
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
Reply With Quote
  #5  
Old 06-05-2012, 07:56 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
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
Reply With Quote
  #6  
Old 12-17-2012, 11:39 AM
Maureen's Avatar
Maureen Maureen is offline
VanDyke Product Director
 
Join Date: Feb 2004
Location: Albuquerque, NM
Posts: 1,612
Quote:
Originally Posted by gregg View Post
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"
A substitution variable for the port has been added to a pre-beta version of SecureCRT. Please send me e-mail at Maureen.Jett@vandyke.com if you would be interested in trying it.

Maureen
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:58 PM.