Forum Discussion

Joe_Tran's avatar
Joe_Tran
Icon for Advisor rankAdvisor
6 years ago

Groovy Expect Scripting -- "]$" prompts

Most of the Linux environments I work with are RHEL or CentOS and our prompts look like:  [username@hostname ~]$ I can't seem to find a prompt pattern that works for both the closing squa...
  • Mike_Rodrigues's avatar
    6 years ago

    @Joe Tran you were close, you should be able to match it with this:

    '\\[.*\\]\\$'

    The expect() method actually takes a Java Pattern which is compiled down to a Regex object.

    You can see if your Pattern converts to the expected Regex by using:

    println Pattern.compile('yourpatternstring')

    We should really add a method that takes a plain old regex, sorry for any confusion. Let me know if the above doesn't work for you.