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 12-02-2008, 01:08 AM
hengliang hengliang is offline
Registered User
 
Join Date: Oct 2008
Posts: 8
Regular expression support with WaitForStrings

Hi,

I used to write Expect scripts and I really missed the capability to wait on a string using regular expression. Is there a plan to incorporate such functionality in SecureCrt?

Regards,
Heng-Liang
Reply With Quote
  #2  
Old 12-02-2008, 08:28 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi hengliang,

Implementation of such a feature is still under consideration for a future release of SecureCRT.

In the event that a version of SecureCRT is made available in which this feature has been implemented, we will post to this forum thread. If you would like to be contacted personally, feel free to send us a note with your request, and include a reference to this forum thread (3319).

In the meantime, there may be a workaround to accomplish that same goal of waiting for a certain pattern, but I will need a little more information.

Could you explain more about what type of pattern you would be looking for, as well as the action that would be taken once that pattern was found?
Reply With Quote
  #3  
Old 12-03-2008, 09:50 AM
hengliang hengliang is offline
Registered User
 
Join Date: Oct 2008
Posts: 8
In the code below, I was waiting for only a single character "-". The 5 characters before that is a space following by 4 hexadecimal number; there is no way to know in advance what the value of the 4 hexadecimal number would be.

For sunny day scenario, there should be one and only one "-" character after "m 0x400000de" is sent; the code below therefore is ok.

My concern is that there may be a rainy day scenario where by "-" will also appear. In the event of such a rainy day scenario, I would like the script to stop but the code below would surely continue.

If I could wait for more characters to appear before proceeding, there is a higher chance that the script will not continue should there be any error with the system. Because there is no way to know in advance the value of the 4 hexadecimal number, the ability to wait on a regular expression would be helpful.

------------------------------------------------------
ExeVxWorksCommand hsim2_num, "d 0x40000000"

crt.Screen.Send "m 0x400000de" & chr(13)
crt.Screen.WaitForString "-"
crt.Screen.Send "ff00" & chr(13)
Reply With Quote
  #4  
Old 12-03-2008, 10:37 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 132
Hi Hengliang,

The only way I know of doing this would be to add a waitfor with a timeout. That way if a second "-" appeared, then the script could exit. Something like this where there is a 10 second wait for a second "-". If not found, the script would continue:

Quote:
crt.Screen.Send "m 0x400000de" & chr(13)
crt.Screen.WaitForString "-"
result = crt.Screen.WaitForString "-", 10
if result <> 0 then
exit sub
end if
(Though Regular Expression Support is still needed! LOL)

Wes

Last edited by WesR; 12-03-2008 at 11:26 AM.
Reply With Quote
  #5  
Old 12-04-2008, 11:04 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi hengliang,

Can you provide example screen output that shows both the success and failure case?
Reply With Quote
  #6  
Old 12-04-2008, 07:24 PM
hengliang hengliang is offline
Registered User
 
Join Date: Oct 2008
Posts: 8
Hi WesR, thanks for your code but we are not talking about a second "-" appearing. The error scenario is unpredictable and I am exploring how to reduce the chance of a script continuing when the system is exhibiting responses for which the code is not designed to handle.

Hi kbarnette, for the platform i am dealing with, I have not seen a failure case myself and I do not know how to trigger one.

This underscores why I requested for regular expression support in the first place. To wait on just one character alone is risky. Waiting on more character is safer.

Last edited by hengliang; 12-04-2008 at 07:33 PM.
Reply With Quote
  #7  
Old 12-04-2008, 07:42 PM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 132
Hi Hengliang,

If this code is in the Main subroutine, then it will exit the script if a second "-" is seen within 10 seconds after the first. This may not meet your needs, but it should work within the parameters I specified. I use similar code all the time.

Code:
Sub Main

crt.Screen.Send "m 0x400000de" & chr(13)
crt.Screen.WaitForString "-"                 'Wait for first -
result = crt.Screen.WaitForString "-", 10    'Wait for second -, with timeout
if result <> 0 then                          'If it is a timeout, then
   exit sub                                  'Exit the routine
end if
crt.Screen.Send "ff00" & chr(13)

End Sub
Wes
Reply With Quote
  #8  
Old 12-05-2008, 07:14 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi hengliang,

Thanks for the response.

As I mentioned previously, we will post here in the event that regular expression support is added to the SecureCRT objects.
Reply With Quote
Reply


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 01:36 PM.