Super Contributor.. Chuck Perilli Super Contributor..
Super Contributor..
496 views

Cannot get RegEx to work with SSH Commands operation expect

Expect works looking for a simple text string but I cannot get it to work with a regular expression.  In this case I want to find a prompt is either "$" or ">".  This works fine as long as the prompt is "$":

expect $
send pwd
expect $
send echo yada yada yada

But in some cases, prompt may be ">".  So I tried this:

expect (\$|>)
send pwd
expect (\$|>)
send echo yada yada yada

Flow just hangs on the operation.  I've played with variations on the RegEx and nothing seems to work.  Any ideas?  BTW, running HPOO 10.22.  Thanks!

-Chuck

 

Tags (1)
0 Likes
4 Replies
Walt Trusted Contributor.
Trusted Contributor.

Re: Cannot get RegEx to work with SSH Commands operation exp

use
expect >

 

0 Likes
Super Contributor.. Chuck Perilli Super Contributor..
Super Contributor..

Re: Cannot get RegEx to work with SSH Commands operation exp

One problem with that solution...it won't see a $ prompt.  I need to detect EITHER $ or >.

0 Likes
Outstanding Contributor.. JarodMB Outstanding Contributor..
Outstanding Contributor..

Re: Cannot get RegEx to work with SSH Commands operation exp

What about: 

expect /(.)>|$

or maybe 

expectEndsWith >|$

0 Likes
Super Contributor.. Chuck Perilli Super Contributor..
Super Contributor..

Re: Cannot get RegEx to work with SSH Commands operation exp

What about: 

expect /(.)>|$    Does not wait for > or $, accepts anything as a valid prompt.

or maybe 

expectEndsWith >|$  Script hangs.

 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.