Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Notices

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 06-21-2012, 07:04 PM
gates2010 gates2010 is offline
Registered User
 
Join Date: Jun 2012
Posts: 19
Script or button cmd to open the log file of the current active window

Hi,

I have auto-logging setup for all my securecrt sessions intentionally, and I usually have multiple windows opened for the same server doing different things, this turns out to be an issue when I try to identify the log file thats realted to the active window.

Most of the times I only need to know the log file for a particular active window, so I am trying to see if the menu option in the button bar or a script that I can use in a button to open the log file related to the active window. Please share if you have already solved this issue. Appreciate the info.

I have attached the screenshot my my logging settings for your reference.

  #2  
Old 06-22-2012, 07:38 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi gates2010,

It is possible to open the log file for the active tab. Here is a Python example that illustrates how to open the log file for the active tab:
PHP Code:
import os
MsgBox 
crt.Dialog.MessageBox

def ViewLog
():
    
objCurTab crt.GetActiveTab()
    
strCurLogFile objCurTab.Session.LogFileName
    
try:
        
os.startfile(strCurLogFile)
    
except IOError:
        
MsgBox("Couldn't Open Log File!")
        
ViewLog() 
You could map this script to a button to open the log file for the active tab. Does this help you accomplish your goal?

As a note, this script example is for Windows only.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
  #3  
Old 06-22-2012, 10:04 AM
gates2010 gates2010 is offline
Registered User
 
Join Date: Jun 2012
Posts: 19
Thanks a lot!

Todd,

That works perfectly!!! thats what I was looking for, thank you very much.
  #4  
Old 06-12-2013, 08:03 PM
gates2010 gates2010 is offline
Registered User
 
Join Date: Jun 2012
Posts: 19
Question Follow-up

Hi,

I have a follow-up question to my request earlier...


I am still using the script shared above to "open" the log file just using the button from the bar... this has helped me immensely...


I would like to check if its possible to copy the name of the file to the clipboard as well on clicking the "open" button from the button bar..

i am now saving log file names for future reference and everytime i need to do that i have to do a "save as" in notepad++ which doesn't have a shortcut key and then copy the filename from there...

if the log file can be opened and also filename be copied to the clipboard that will be extremely awesome... kindly share if thats doable!...


thank you in advance...
  #5  
Old 06-13-2013, 09:28 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi gates2010,

I modified the original example to be multi-platform, and added a single line to set the clipboard. Here is the new and improved example:
Code:
import subprocess, os, sys, platform
MsgBox = crt.Dialog.MessageBox

def ViewLog():
    objCurTab = crt.GetActiveTab() 
    strCurLogFile = objCurTab.Session.LogFileName
    crt.Clipboard.Text = strCurLogFile
    try:
        if sys.platform.startswith('darwin'):
            subprocess.call(('open', strCurLogFile)) 
        elif os.name == 'nt': 
            os.startfile(strCurLogFile) 
        elif os.name == 'posix': 
            subprocess.call(('xdg-open', strCurLogFile)) 
    # SecureCRT on Mac uses Python 2.5, so use old syntax.
    # Python 2.7 syntax:
    # except Exception as strError:
    except Exception, strError:
        MsgBox("Failed to open file with default editor:\r\n\r\n" + strCurLogFile + "\r\n\r\n" + strError)

ViewLog()
Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
  #6  
Old 06-13-2013, 10:33 AM
gates2010 gates2010 is offline
Registered User
 
Join Date: Jun 2012
Posts: 19
Thumbs up Thank you, a lot

Thanks a lot, thats what i needed.. now its a lot easier for me..
Closed Thread

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:27 AM.