Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-05-2019, 07:00 AM
kammmo kammmo is offline
Registered User
 
Join Date: Sep 2019
Posts: 4
Lightbulb 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
Reply With Quote
  #2  
Old 09-05-2019, 07:33 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,976
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 09-05-2019, 08:02 AM
kammmo kammmo is offline
Registered User
 
Join Date: Sep 2019
Posts: 4
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
Reply With Quote
  #4  
Old 09-05-2019, 08:19 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,976
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)?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 09-18-2019, 02:04 AM
kammmo kammmo is offline
Registered User
 
Join Date: Sep 2019
Posts: 4
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
Reply With Quote
  #6  
Old 09-18-2019, 07:54 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,976
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?)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 09-18-2019, 09:24 AM
kammmo kammmo is offline
Registered User
 
Join Date: Sep 2019
Posts: 4
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
Reply With Quote
  #8  
Old 09-18-2019, 11:20 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,976
Hi Kamil,

No, sorry, I don't. Just the feature request.
__________________
Thanks,
--Brenda

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

Tags
cisco , regular expression , waitforstrings


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