Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expect Scripting

Tags:

expect

tcl

I am trying to match a text which contains the " ", from the log file. But it doesn't match. I understand that " " has got a special meaning to TCL/Expect.

Hence I tried the following, but no luck.

expect -ex {
            "lp -c -demail -ot\\\"[email protected]\\\" /usr/local/spool/pf"
            {
               incr logged
               send_user "\r\n LOGGED #4, $logged \r\n"
            }
            timeout

I tried to use , \ and \\ but no luck yet.

My log file contains the following line,

exec [lp -c -demail -ot"[email protected]"  /usr/local/spool/pf/context/ABC001-1209236.mime]

and I need to match that line.

like image 791
suj Avatar asked Aug 26 '26 15:08

suj


1 Answers

Use {} quotes, which are similar to shell's single quotes. Also Tcl is sensitive to newlines, so you have to put the opening brace of a block on the previous line

expect {
    {lp -c -demail -ot"[email protected]" /usr/local/spool/pf} {
       incr logged
       send_user "\r\n LOGGED #4, $logged \r\n"
     }
     timeout
}
like image 188
glenn jackman Avatar answered Aug 28 '26 07:08

glenn jackman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!