How can I assign a variable using $expect_out in TCL/EXPECT?

后端 未结 3 815
[愿得一人]
[愿得一人] 2021-02-09 02:14

If I want to match DEF_23 using the following regexp:

expect {
    -re \"DEF_\\[0-9]*\"
    set result $expect_out(1,string)
}

why

3条回答
  •  孤街浪徒
    2021-02-09 02:57

    Aleksandar - it should work if you change the match to "\ndb.*$".

    If you turn on exp_internal 1, you will see the buffer contains something like this: "ls -1 db*\r\ndbupgrade.log\r\n08:46:09"

    So, the caret (^) will throw your pattern match off.

提交回复
热议问题