Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-28-2010, 04:24 PM
bbrunette bbrunette is offline
Registered User
 
Join Date: Oct 2008
Posts: 7
Logging to a directory and filename

I want to write a script that determines the log filename from the system prompt and then presents the "Select Log File" dialog box to let the user select the directory to put the file in. In other words, do the normal File/Log Session behavior, except have a variable default filename instead of "session.log" or the pre-defined session log filename.

I've done the first part (determine the filename from the system prompt), but can't figure out how to get the dialog box displayed.

Does anybody have any ideas?

If it isn't currently possible, I'm thinking a crt.Session.LogDialog(varname) method, where 'varname' is the default log filename, would be nice.

By the way, I've ported all my scripts to Python and am doing this one in Python too.

Thanks,
Bob
Reply With Quote
  #2  
Old 12-28-2010, 04:59 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Bob,

It sounds like you are looking for the ability to allow the user to browse to a location to use for logging. I am not a Python expert, so I am not sure if this is possible or not.

If it would be acceptable to prompt the user for a location to write the log file, and have that default to a specific name, then this could be done using the Dialog object.

For example:
Code:
strLogFileName = crt.Dialog.Prompt("Enter the path for the log file:", "Logging Location", "c:\temp\", False)

if strLogFilepath == "":

  # User clicked Cancel button

else:

  # User added data
You could then use the LogFileName property of the Session object to set the path that the user entered.

Would this meet your needs?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 12-29-2010, 11:21 AM
bbrunette bbrunette is offline
Registered User
 
Join Date: Oct 2008
Posts: 7
Todd,
Your interpretation is correct--I'd like to give the user the ability to browse and select a directory for the log file. Using the prompt dialog box to enter the directory name isn't quite what I had in mind.

Bob
Reply With Quote
  #4  
Old 12-29-2010, 12:41 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Bob,

Thanks for the confirmation. I have created a feature request in our SecureCRT development database to add an API for browsing files. Should a future release of SecureCRT have this capability, we will post to this forum thread.

If you would like to be notified directly, please complete and submit the form at the following location:
Submit Feature Request
In the meantime, you may be able to find some information on the internet regarding this topic in forums more specifically geared to the Python language.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 12-29-2010, 01:14 PM
bbrunette bbrunette is offline
Registered User
 
Join Date: Oct 2008
Posts: 7
I figured out two ways to do this. The first has a problem and the second works fine. I'll show both to stimulate creative thinking.

Both methods start by using object.LogFileName to set the log filename. The filename you specify is then used in subsequent logging operations. Both also rely upon the Global Session option "Prompt for filename" being checked. I suppose you could use object.SetOption to force it, but I haven't tried that.

The first method then uses object.LogUsingSessionOptions(). The "Select Log File" dialog box is displayed so that the user can select the directory (or override the filename, for that matter). The problem is that if the user presses the Cancel button, you get a "Failed to open log file" script error.

And now the second method, which works well. After setting the log filename, use crt.Screen.SendSpecial("MENU_LOG_SESSION") to display the "Select Log File" dialog box. With this method, there are no errors if the user cancels.

One minor complaint (I'm hard to satisfy): It would be nice if I could get the script to pause execution while the dialog box is open. I could then check the logging status using crt.Session.Logging and update the status bar text accordingly.

That's about all I have to say on this subject, unless somebody else chimes in.

Bob
Reply With Quote
  #6  
Old 12-29-2010, 04:00 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Bob,

I think that I may have a possible solution to the problems you encountered trying to work around the lack of a file browsing API in SecureCRT.

Please send an e-mail to support@vandyke.com with a subject of Attn: Todd - Forum thread #6687 for further details.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #7  
Old 01-05-2011, 05:07 PM
Maureen's Avatar
Maureen Maureen is offline
VanDyke Product Director
 
Join Date: Feb 2004
Location: Albuquerque, NM
Posts: 1,534
The ability to open a file browser dialog from a script has been added to a pre-beta version of SecureCRT. If you would be interested in trying it, please send e-mail to me at Maureen.Jett@vandyke.com.

Maureen
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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