« Return to Thread: Plus character in EXPECT string gives "Invalid preceding regular expression" error

Re: Plus character in EXPECT string gives "Invalid preceding regular expression" error

by Jan-Henrik Haukeland :: Rate this Message:

| View in Thread


On Jan 14, 2012, at 8:25 PM, Lukasz Piwowarek wrote:

> Hi
>
>  
> I am trying to use Monit to check Redis DB like this:
>
>  
>         if failed port 6379
>
>                 send "PING"
>
>                 expect "+PONG"
>
>                 send "SET monit_test_key \r\nalive\r\n"
>
>                 expect "+OK"
>
>                 send "EXISTS monit_test_key\r\n"
>
>                 expect ":1"
>
>         then
>
>                 restart
>
>  
> The issue is Monit reads the + character as a regular expression and throws an error on start: Invalid preceding regular expression.
>
>  
> Is there some way around this?

Escape the + or use a character class. That is, either

         expect "\+PONG"
or
         expect "[+]PONG"


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

 « Return to Thread: Plus character in EXPECT string gives "Invalid preceding regular expression" error