Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Reply
 
Thread Tools Display Modes
  #1  
Old 08-25-2016, 03:02 AM
kingboli kingboli is offline
Registered User
 
Join Date: Aug 2016
Posts: 5
Smile Help: log and quit

Hi guys,
Can you help me on below three questions?

1. How can I record the screen output to a log file using command not the GUI settings?

2. How can I append a fixed log file with every screen output everytime I launch SecureCRT?

3. How can I quit the application? I tried crt.Quit and crt.Session.Disconnect but it did not work.

Below are my py script:

def main():

crt.Screen.WaitForString("$")

crt.Screen.Synchronous = True
crt.Screen.Send("ls \r")

promptString = "=>"
crt.Screen.WaitForString(promptString)

crt.Screen.Synchronous = False
crt.Session.Disconnect
crt.Quit

main()


Great thanks.
Reply With Quote
  #2  
Old 08-25-2016, 11:08 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,024
Quote:
Originally Posted by kingboli View Post
2. How can I append a fixed log file with every screen output everytime I launch SecureCRT?
Something like this screen shot shows a configuration that you can apply not only to one session but also to your Default session (which can be applied to all of your existing sessions):
Log file name: C:\SecureCRT Logs\%Y%M%D_%h%m%s.%t(%S,%H).txt
[x] Start log upon connect (enable it)

If you want to have each line of your log file time-stamped, you can do that, too, as shown in the orange box of the above screen shot.
On each line: %Y%M%D %h:%m:%s(%t):

Available substitutions (%Y, etc.) are documented in SecureCRT's help file. For example:
Note that if you mistype any of the substitution parameters, SecureCRT won't know how to interpret what you've specified, and you'll be prompted for a log file name when logging starts. If you're prompted for a log file name even though you don't have the "Prompt for filename" option enabled, it's because you've mistyped some portion of the log file name and it's invalid. Also, remember that filenames cannot have : characters or other special characters, so though you may be tempted to insert a : character (like for time-stamped log file names), resist it!

Also, make sure you have the "Start log upon connect" option enabled so that SecureCRT will automatically begin logging when you connect to a remote host, so you don't have to remember to choose File > Log Session each time before you connect.

Quote:
Originally Posted by kingboli View Post
1. How can I record the screen output to a log file using command not the GUI settings?
Assuming you have your session configuration set to the above, logging will happen automatically to log files that will have the substitutions replaced with actual value.

You can control logging from within a script by using the crt.Session object and its corresponding "Log*" methods and properties, all of which are documented in SecureCRT's built-in help. For instance:
Quote:
Originally Posted by kingboli View Post
3. How can I quit the application? I tried crt.Quit and crt.Session.Disconnect but it did not work. Below are my py script:
Code:
def main():
	
	crt.Screen.WaitForString("$")
	
	crt.Screen.Synchronous = True
	crt.Screen.Send("ls \r")

	promptString = "=>"
	crt.Screen.WaitForString(promptString)
	
	crt.Screen.Synchronous = False
        crt.Session.Disconnect
        crt.Quit

main()
I've tried your code, too, and it looks like neither the crt.Screen.Disconnect(), nor the crt.Quit() are functioning as expected.

I've created a bug report for our QA/DEV team to look into and I'll post here with updates as they become available to me.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 08-25-2016, 07:31 PM
kingboli kingboli is offline
Registered User
 
Join Date: Aug 2016
Posts: 5
Great thanks for your help.
And I look forward to solutions of quiting applications.
Reply With Quote
  #4  
Old 08-29-2016, 11:26 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,024
crt.Session.Disconnect() and crt.Quit() need parens in python. Otherwise, I suppose the code is simply referring to the reference to the function (which is essentially a no-op).

If you update your script code to have ()s after Disconnect() and Quit(), you'll see them start to work.

Sorry I missed this obvious one earlier.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 08:16 PM.