Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #16  
Old 10-11-2016, 11:33 AM
corp-mule corp-mule is offline
Registered User
 
Join Date: Mar 2006
Posts: 21

I have the same problem. And the solution within this thread did not resolve it.

I'm trying to capture the output of the "sh run" command on a Cisco router. The output is a little bit over 4400 lines. But the log file only has a little over 1850.

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

' **************************************
' **************************************
'     WARNING - WARNING - WARNING
' **************************************
' **************************************
'
' This script works ... BUT ...
'
' The log file does not contain *ALL* the output!!!
'
' I have not been able to find the cause or solution.
'
' This URL addresses the issue but, the solution
' within this thread, does not solve the problem for me.
'
' Logging long output issue - VanDyke Software Forums
' https://forums.vandyke.com/showthread.php?t=11908
'
' **************************************
' **************************************

' This script will ...
'
' - Stop the current (generic session)
'   logfile

' - Then starts a new logfile to capture
'   output from specific "show comamnds"

' - Then, stop the "specific logfile"

' - Then start a new generic session
'   logfile.
'

  ' Turn on synchronous mode while performing Send/Wait sequences
  ' so no input is missed.
  '
  crt.Screen.Synchronous = True
'

' Specify a log file name that is time-stamped (with legal
' filename characters). This way, the files can be sorted
' easily within Windows Explorer.
'
' crt.Session.LogFileName = _
'
' "C:\Temp\Logs\%Y-%M-%D--%h-%m-%s.%t-%S(%H).txt"


Sub Main

' If you are unsure whether or not logging has been enabled
' already, you can determine this programmatically with an
' If statement within your script code:

'If crt.Session.Logging <> True Then
'crt.Session.Log True
'End If

' If at any point within your script code, you desire to
' turn off logging, simply use the Session.Log method,
' providing an argument of False. For example:
'
' crt.Session.Log False
'
' If logging is already enabled, and you want to ensure that
' specific log settings are active (using a specific log
' file name, append vs. overwrite, etc.), then you may want
' to stop the logging process, configure log settings within
' your script, and then enable logging as per your
' requirements. For example:
'
' --- If crt.Session.Logging Then
' --- ' Turn off logging before setting up our script's
' --- ' logging...
' --- crt.Session.Log False
' --- End If
'
' If using a pre-configured session ...
'
If crt.Session.Logging Then
'
' Turn off logging before setting up our script's logging...
'
crt.Session.Log False
End If
'
' Set up the log file so that it resides in the path
' defined in the TEMP environment variable, and is
' named according to the remote IP address:
'
' crt.Session.LogFileName = "%TEMP%\" & _
' "LogFileForIP(" & crt.Session.RemoteAddress & ").txt"
' crt.Session.LogUsingSessionOptions
'
' I:\files\logs\securecrt\%H--%M-%D--%h-%m.log
crt.Session.LogFileName = "I:\files\logs\securecrt\" & _
"sh-run---%S--%M-%D--%h-%m.log"
crt.Session.LogUsingSessionOptions
'
' Send commands, etc.
' ...
'
' Get hostname from session
Set objTab = crt.GetScriptTab()
Set objConfig = objTab.Session.Config
strHostname = objConfig.GetOption("Hostname")
strPrompt = strHostname & "#"


''''''''''''''''''''''''''''''''''''''''
        CRT.Screen.SendSpecial "MENU_CLEAR_SCREEN_AND_SCROLLBACK"
        'CRT.Screen.SendSpecial "MENU_CLEAR_SCROLLBACK"
	crt.Screen.Send "!" & chr(13)
	
	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "term len 0" & chr(13)
 	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "sh clock" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "sh run" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "sh clock" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "term len 24" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	' 900000 = 15 minutes
	' 1800000 = 30 minutes
	' 3600000 = 1 hour
        'crt.Sleep 900000



''''''''''''''''''''''''''''''''''''''''
'
' Turn off synchronous mode
crt.Screen.Synchronous = false
'
' Stop logging
'
'crt.Session.Log False
'
' Perform other script work, or setup on the remote for the
' next batch of logging...
' ...
' Start logging again (be sure to append or else we'll
' overwrite the data we've logged so far).
'
'crt.Session.Log True, True
'
'
' If using a pre-configured session ...
'
If crt.Session.Logging Then
'
' Turn off logging before setting up our script's logging...
'
crt.Session.Log False
End If
'
' Turn on logging;
'
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	crt.Screen.Send "!" & chr(13)

	crt.Screen.WaitForStrings strPrompt, "#"
	'crt.Sleep 5000
crt.Session.LogFileName = "I:\files\logs\securecrt\" & _
"%S--%M-%D--%h-%m.log"
crt.Session.LogUsingSessionOptions
'crt.Screen.WaitForStrings strPrompt, "#", 5
'crt.Sleep 5000
'
'
' Send more commands, etc.
' ...
' ...
End Sub
Reply With Quote
 

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:12 PM.