Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-02-2016, 01:37 PM
corp-mule corp-mule is offline
Registered User
 
Join Date: Mar 2006
Posts: 21
How does "crt.Sleep" work?

How does "crt.Sleep" work? What triggers it?

It seems things in the script do not happen in the order that I put them ... into the script.

I want to ...

- Stop the current log file. Call this the "first log file."

- Start a "second log file" and save it in a different location.

- Run three commands and log the output into the "second log file" log file.

- Loop the third command until I stop it manually, logging the output into the "second log file."

- Stop the "second log file" log file.

- Then start a "thrid log file" (or continue the first one).

I put the "sleep" command *_AFTER_* three "show commands." But ... The script pauses after the first two "show commands," then it runs the third command.

Why does it pause after the "sh clock" command?

Why doesn't the "sleep" command pause **_AFTER_** the third command runs?

Also ...

When I stop the "second log file," ... some of the "show commands" get put into the 3rd log file.

Why don't the "sh clock" (and other commands) go into the "second log file" log file? Why do they end up in the 3rd log file?

The 3rd log file is started *_AFTER_* all the "sh commands" have been run.



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

crt.Screen.Synchronous = True

Sub Main

' 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 = "I:\files\scripts\scrt-vbs-scripts\" & _
"!---test-%H--%M-%D--%h-%m.log"
crt.Session.LogUsingSessionOptions
'
' Send commands, etc.
'
        CRT.Screen.SendSpecial "MENU_CLEAR_SCREEN_AND_SCROLLBACK"
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "term len 0" & chr(13)
 	crt.Screen.WaitForString "#"
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "sh clock" & chr(13)
	crt.Screen.Send chr(13)
	crt.Screen.Send chr(13)
' 
' I want to run the next command at certain intervals, until
' I manually stop it.
' 
' I'd like to make it stop automatically after a specific
' period of time.  If that's possible, I'll have to figure it
' out later, I guess.
' 
' :: PROBLEM ::
' The following command does not run until the "sleep"
' command times out.
'
' Why doesn't the "sleep" command pause **_AFTER_** this
' command runs?
'
Do
	crt.Screen.WaitForString "#"
	crt.Screen.Send "sh ip cache flow | i ddress|0/0/3.334" & chr(13)
	crt.Screen.WaitForString "#"
        crt.Sleep 5000
	crt.Screen.Send chr(13)
	crt.Screen.Send chr(13)
Loop Until crt.Screen.WaitForKey(2)
	'crt.Screen.WaitForString "#"
	crt.Screen.Send "sh clock" & chr(13)
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "term len 24" & chr(13)
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "#"
'
' Turn off synchronous mode
crt.Screen.Synchronous = false
'
' Stop logging
'
' 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;
'
' :: PROBLEM ::
' 
' The "sh clock" command above ends up in the second log
' file below.  Why?
'
' Why doesn't the "sh clock" (and other commands above) go
' into the first log file?
'
	crt.Screen.WaitForString "#"
	crt.Screen.Send chr(13)
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "#"
crt.Session.LogFileName = "I:\files\scripts\scrt-vbs-scripts\" & _
"%S--%M-%D--%h-%m.log"
crt.Session.LogUsingSessionOptions
crt.Screen.WaitForString "#", 5
crt.Sleep 5000
'
' Send more commands, etc.
'
End Sub
Reply With Quote
 

Tags
log , logging , sleep


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 11:24 PM.