#1
|
|||
|
|||
SecureCRT: Script ignores delay and WaitForString commands
Maybe you can help me with my problem: I have a set of commands which has to be sent to devices managed by me, there are lot of commands, which have to be sent just command-by-command, but not too fast, because these commands put heavy load for the system and effect of too fast sending is a crash of it.
So I did it simple: after every command is wait for prompt, lot of additional delay commands, longer delays between block of commands - final script has more than 400 lines, but it seemed to be simple task to do. Unfortunately it isn't: from my PC script is working fine, slow as expected, all delays are included etc. more less to half of it. And, suddenly all the rest of commands are send in one second, without any delays (included in code!) or waitfor prompt, as a result it kills my device ![]() Interesting is that it is connected to my PC only, my colleague has the same version of SecureCRT and from his PC the same script is working fine. My script: Code:
#$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True Sub Main If crt.Session.Connected <> True then MsgBox "Please login to NE first!" Exit Sub end if If crt.Session.Logging <> True then MsgBox "Please enable logging of session" Exit Sub end if crt.Screen.Send chr(13) Dim nResult nResult = crt.Screen.WaitForString("OLT", 3) If nResult = 0 Then MsgBox "No OLT> or OLT# prompt detected!" & "Please login to the GPON card first" Exit Sub End If Dim Sleeptime 'delay between blocks of commands Sleeptime = 10 SecondSleepTime = 1000 LongSleepTime = 15000 crt.Screen.Send chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "term len 0" & chr(13) crt.Screen.Send "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" & chr(13) crt.Screen.Send "! !" & chr(13) crt.Screen.Send "! Triage script !" & chr(13) crt.Screen.Send "! !" & chr(13) crt.Screen.Send "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "show clock" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "show version ver" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "show fpga ver" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! show fpga version " & chr(13) crt.Screen.Send "! (or equivalent)" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display 128 bytes from Z06 base" & chr(13) crt.Screen.Send "show memory 0xD0000000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! Display 64 bytes from Stingray Memory Interface Registers" & chr(13) crt.Screen.Send "show memory 0xD0001000 count 64" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display ETH0 MAC" & chr(13) crt.Screen.Send "show memory 0xD0002000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0002020 0xFFFFFFFF" & chr(13) crt.Sleep Sleeptime crt.Screen.WaitForString "OLT" crt.Screen.Send "mem read long 0xD0002020" & chr(13) crt.Sleep Sleeptime crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display ETH0 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0003000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0003018 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0003034 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0003044 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0003064 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "show memory 0xD0003000 count 128 " & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display ETH1 MAC" & chr(13) crt.Screen.Send "show memory 0xD0004000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0004020 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem read long 0xD0004020" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display ETH1 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0005000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0005018 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0005034 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0005044 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0005064 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "show memory 0xD0005000 count 128 " & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display ETH2 MAC" & chr(13) crt.Screen.Send "show memory 0xD0006000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0006020 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem read long 0xD0006020" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display ETH2 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0007000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0007018 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0007034 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0007044 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0007064 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "show memory 0xD0007000 count 128 " & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display ETH3 MAC" & chr(13) crt.Screen.Send "show memory 0xD0008000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0008020 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem read long 0xD0008020" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display ETH3 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0009000 count 128" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "mem write long 0xD0009018 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0009034 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0009044 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "mem write long 0xD0009064 0xFFFFFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep Sleeptime crt.Screen.Send "show memory 0xD0009000 count 128 " & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display PON1 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0010000 count 64" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display PON2 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0011000 count 64" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display PON3 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0012000 count 64" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Screen.Send "! Display PON4 SERDES" & chr(13) crt.Screen.Send "show memory 0xD0014000 count 64" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Sleep Sleeptime crt.Sleep Sleeptime crt.Sleep Sleeptime crt.Screen.Send "! START_OF_PON1" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "debug gpon counters 0 0" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 2" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 3" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 4" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 5" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 6" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 7" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 8" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 9" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 0xC" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 0 0xFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Sleep SecondSleepTime crt.Screen.Send "! Display 4096 bytes from GPON base" & chr(13) crt.Screen.Send "show memory 0xD0100000 count 2048" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! Clear counters" & chr(13) crt.Screen.Send "! then wait 15 sec" & chr(13) crt.Sleep LongSleepTime crt.Screen.Send "debug gpon counters 0 0xFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! END_OF_PON1" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "! START_OF_PON2" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "debug gpon counters 1 0" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 2" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 3" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 4" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 5" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 6" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 7" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 8" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 9" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 0xC" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 1 0xFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Sleep SecondSleepTime crt.Screen.Send "! Display 4096 bytes from GPON base" & chr(13) crt.Screen.Send "show memory 0xD0120000 count 2048" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! Clear counters" & chr(13) crt.Screen.Send "! then wait 15 sec" & chr(13) crt.Sleep LongSleepTime crt.Screen.Send "debug gpon counters 1 0xFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! END_OF_PON2" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "! START_OF_PON3" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "debug gpon counters 2 0" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 2" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 3" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 4" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 5" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 6" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 7" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 8" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 9" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 0xC" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 2 0xFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "!" & chr(13) crt.Sleep SecondSleepTime crt.Screen.Send "! Display 4096 bytes from GPON base" & chr(13) crt.Screen.Send "show memory 0xD0140000 count " & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! Clear counters" & chr(13) crt.Screen.Send "! then wait 15 sec" & chr(13) crt.Sleep LongSleepTime crt.Screen.Send "debug gpon counters 2 0xFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! END_OF_PON3" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "! START_OF_PON4" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "debug gpon counters 3 0" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 2" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 3" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 4" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 5" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 6" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 7" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 8" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 9" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 0xC" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "debug gpon counters 3 0xFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep SecondSleepTime crt.Screen.Send "!" & chr(13) crt.Screen.Send "! Display 4096 bytes from GPON base" & chr(13) crt.Screen.Send "show memory 0xD0160000 count 2048" & chr(13) crt.Screen.WaitForString "OLT" crt.Screen.Send "! Clear counters" & chr(13) crt.Screen.Send "! then wait 15 sec" & chr(13) crt.Sleep LongSleepTime crt.Screen.Send "debug gpon counters 3 0xFFFF" & chr(13) crt.Screen.WaitForString "OLT" crt.Sleep LongSleepTime crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "! END_OF_PON4" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "!" & chr(13) crt.Screen.Send "show clock" & chr(13) crt.Screen.Send "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" & chr(13) crt.Screen.Send "! End of script !" & chr(13) crt.Screen.Send "! !" & chr(13) crt.Screen.Send "! Please rerun this script !" & chr(13) crt.Screen.Send "! 2-3 times every minute !" & chr(13) crt.Screen.Send "! !" & chr(13) crt.Screen.Send "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" & chr(13) crt.Screen.Send "!" & chr(13) End Sub |
#2
|
|||
|
|||
Hi jarek.p,
It is not recommended to rely on Sleep() calls to pace your script. For every Send(), you should have a corresponding WaitForString(). You might look at the script posted here which is designed to pace the sending of commands to match what the device can handle.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi,
Thx for answer but have a look, I have included WaitForString() after near every "Send" command, Sleep was added for reach additional time between commands. But question is why it is ignored (WaitForString together with sleep) in the second half of code. Is any limitation for them? |
#4
|
|||
|
|||
Hi jarek.p,
Quote:
Having a WaitForString() for nearly every Send() is often not quite good enough! ![]() I see five, eight, even 14 Send() calls in a row in various places in the script. As for the eight Send() calls at the very end of the script, did you know Send() has an optional parameter to send just to the screen? What version of SecureCRT are you using? Quote:
![]() Having multiple Send() calls without a corresponding WaitForString() causes scripts to get out of sync.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
Ok, clear. I was just sure that I don't need to wait for prompt after every command contains sending a comment only -> that was a reason of my "near".
But it was a reason, I edited my script, and added wait for prompt after every send command and now it works perfect, thanks ![]() |
#6
|
|||
|
|||
Hi jarek.p,
I know, it seems excessive and it's a big undertaking in a script that size, but it's definitely a "best practice" and makes the script more stable. I am glad to hear of your success! ![]()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
script , securecrt 8 , visual basic |
Thread Tools | |
Display Modes | Rate This Thread |
|
|