Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-18-2015, 06:43 AM
Sansone Sansone is offline
Registered User
 
Join Date: Feb 2015
Posts: 7
Logging long output issue

Hi,

I want to create a single log file containing only the output of a list of "show commands" on a single Cisco router ( or "display commands on a Huawei router). The output can be very long (more than 1,000 rows). I have disabled paging using "terminal monitor 0" on Cisco or "screen-length 0 temporary" on Huawei. I'm using preconfigured sessions with Log file always enabled.

I can log all the output using the "session option - log file", but I would like to save "the ouputs" in a different log file.

I have prepared a vbs script to stop "default logging", create a new log file, send the commands, and restore "default logging". Unfortunately I manage to log only the first rows. Could you help me?

This is the script I'm using.

Code:
#$language = "VBScript"
#$interface = "1.0"

' This script captures the running-config to a specific logfile, 
' then restore default logging configuration.

Sub Main

	' Turn on synchronous mode while performing Send/Wait sequences
	' so no input is missed. 
	crt.Screen.Synchronous = True
	
	If crt.Session.Logging Then
		' Turn off logging before setting up our script's logging...
		crt.Session.Log False
	End If
	
	' Set up the config log file
	crt.Session.LogFileName = "temporary log.log"
	
	' Setup CLI (Cisco)
	crt.Screen.Send "!" & chr(13)
	crt.Screen.WaitForStrings "#", ">", 5
	crt.Screen.Send "enable" & chr(13)
	crt.Screen.WaitForStrings "#", ">", 5
	crt.Screen.Send "terminal length 0" & chr(13)
	crt.Screen.WaitForString "#", 5
	
	' Enable logging
	crt.Session.Log True
	
	' Show a very long output (Cisco)
	crt.Screen.Send "show tech-support" & chr(13)
	crt.Screen.WaitForString "#", 15
	
	' Turn off logging
	crt.Session.Log False
	
	' Restore the default log file
	crt.Session.LogFileName = "default log.log"	
	
	' Turn on logging
	crt.Session.LogUsingSessionOptions
End Sub
Reply With Quote
  #2  
Old 03-18-2015, 08:07 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Sansone,

Thanks for the post. I am sorry to hear about the problem.

What version of SecureCRT are you using?

What operating system are you using?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 03-18-2015, 10:13 AM
Sansone Sansone is offline
Registered User
 
Join Date: Feb 2015
Posts: 7
Quote:
Originally Posted by rtb View Post
Hi Sansone,

Thanks for the post. I am sorry to hear about the problem.

What version of SecureCRT are you using?

What operating system are you using?

Hi rtb,

I have the latest release of SecureCRT: version 7.3.2 (x64 build 752) - Official Release - February 26, 2015.

I have Windows 7 Professional SP1 64bit.

Do you think that a different script based on "TextStream Write/WriteLine" could be a workaround?
Reply With Quote
  #4  
Old 03-18-2015, 12:38 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Sansone,

I tested your script in SecureCRT 7.3.2, and didn't have any difficulty capturing the entire output of a command. I don't have a Cisco device to test against, but it did work against a UNIX machine.

If you are only capturing a portion of the data in the log file, my guess is that the string you are waiting for to know if the command is complete is just not unique enough.

Is it possible that the "#" character is present in the output of the command?

If it is, then I don't think another approach will work any better.

If you modify your script to wait for the entire prompt, do you get better results?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 03-18-2015, 04:27 PM
Sansone Sansone is offline
Registered User
 
Join Date: Feb 2015
Posts: 7
Hi rtb,

You've probably found the issue: the "#" or "]" characters used in the "crt.Screen.WaitForString" are present in the output of the command.

Can I use a regex, such as "%S#" or "[%S]", in the "crt.Screen.WaitForString"?
Reply With Quote
  #6  
Old 03-18-2015, 05:19 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Sansone,

Currently, WaitForString() does not allow the use of regular expressions. We will post to this thread if we add this in a future release.

Do you have any other way to make the string more unique?

What does "%S" represent?

Do you have the prompt string saved in the session anywhere?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply

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 05:45 PM.