VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   WaitForStrings as regular expresions (https://forums.vandyke.com/showthread.php?t=13899)

kammmo 09-05-2019 07:00 AM

WaitForStrings as regular expresions
 
Hello there,

i am looking on the console output in a loop

Code:

vWaitFors = Array(":&>", _
 "#", _
 "@", _
 ">")

Do
        If crt.Screen.WaitForStrings(vWaitFors) Then
               
                Set objTab = crt.GetScriptTab()
                nRow = objTab.Screen.CurrentRow
                szPrompt = objTab.screen.Get(nRow, 0, nRow, objTab.Screen.CurrentColumn - 1)
               

               
                If reNhop.Test(szPrompt) = True Then

problem is that in case that i list maybe 500 lines, and in each the script will recognize something from the vWaitFors, output is displaying pretty slowly on the screen (CPU going around 35%).

Is there any way to check not basic strings (like "#" for example), but regular expression (like "^(\w+)#" - enable mode on cisco) ??

Many thank for replies

bgagnon 09-05-2019 07:33 AM

Hi kammmo,

That functionality is not available at this time.

I have added this thread to a feature request in our product enhancement database to add regular expression support to scripting in WaitForString() and WaitForStrings(). Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #13899 in the subject line or use this form from the support page of our website.

kammmo 09-05-2019 08:02 AM

Hi Brenda.

THanks for fast reply. :)

Is there any way how to check the CurrentRow in 1 sec intervals?? When i am doing it in loop, the output is just not showing on screen as script is blocking it.

BR
Kamil

bgagnon 09-05-2019 08:19 AM

Hi Kamil,

What version of SecureCRT are you using?

You can add a one second sleep (crt.sleep 1000), but without knowing your overall objective, I am not sure that is the most efficient handling of the issue.

I only have a very narrow perspective of your script. What are you trying to achieve?

Quote:

problem is that in case that i list maybe 500 lines, and in each the script will recognize something from the vWaitFors...
Are the vWaitFors found in a "false positive sense" (ie: in output, not as part of a prompt, which I assume is when you want to act on them)?

kammmo 09-18-2019 02:04 AM

Hi Brenda,

Version 8.5.3 (x64 build 1867)

script is pretty simple.

I am checking "CurrentRow" of active session. In this row i am checking beginning of the row. I am trying to recognize this string and decide, if i am in enable mode or privilege mode on Cisco device.

Switch> --> enable mode
Switch# --> privilege mode

So the differences is only in one symbol ( > vs # ).

So i am looking on the CurrentRow in a loop, with condition as i wrote

Code:

vWaitFors = Array("#", _
 ">")

If crt.Screen.WaitForStrings(vWaitFors) Then

When one of the symbol is recognized as an output in console, the code inside the "If" is proceed.

This process is pretty slowly when your output has lot of "#" (for example some comments). It is processed on each "#". I wanted to add there regular expression (like "^(\w+)#"). You said the it is not supported now. So i just want to check CurrentRow only each second. I cannot do it in loop as i am checking each "#" all the time.

When i apply "sleep", the console output is not displaying output in real time on the screen, and it is freezed during this 1 second. Output is like blocked in some way. It is not usable.

So is there any way how to check "CurrentRow" in second interval, and do not block output on the screen??

Hopefully i explained it understandable.

BR,
Kamil

bgagnon 09-18-2019 07:54 AM

Hi kammmo,
Quote:

This process is pretty slowly when your output has lot of "#" (for example some comments). It is processed on each "#". I wanted to add there regular expression (like "^(\w+)#"). You said the it is not supported now. So i just want to check CurrentRow only each second. I cannot do it in loop as i am checking each "#" all the time.
Can't you make the # WaitFor more unique to distinguish it from the comment character? (ie: some part of "Switch" name included?)

kammmo 09-18-2019 09:24 AM

Hi

No.

As hostname have some "pattern", but i can describe it only as a regexp. Specially when i have different numbers before #.

Any other idea? :)

Thank you for support

BR,
Kamil

bgagnon 09-18-2019 11:20 AM

Hi Kamil,

No, sorry, I don't. Just the feature request. :)


All times are GMT -6. The time now is 06:20 AM.