This is the command output need to be matched:
[snr_core.serconsole.con info] Telnet console listening to port 42365.
(the port number changes every time)
Code to test it:
#!/tools/AGRtools/bin/expect
exp_internal 1
set timeout 10
spawn bash
set bashId $spawn_id
send_user -i $bashId "\n"
send_user -i $bashId "\[snr_core.serconsole.con info\] Telnet console listening to port 42365.\n"
expect -i $bashId -re "\[snr_core.serconsole.con info\] Telnet console listening to port \[0-9]*\." {send_user "The output is $expect_out(0,string)\n"}
====================================
It send_user a line, the same as the expected output, then catch it and display $expect_out(0,string).
This is the debug output:
spawn bash
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {115854}
[snr_core.serconsole.con info] Telnet console listening to port 42365.
expect: does "" (spawn_id exp4) match regular expression "[snr_core.serconsole.con info] Telnet console listening to port [0-9]*."? no
antxec10:/user_workspace/master/tools/AcpTestTool:
expect: does "\u001b]0;ecuser@antxec10:~/user_workspace/master/tools/AcpTestTool\u0007\u001b[?1034hantxec10:/user_workspace/master/tools/AcpTestTool:" (spawn_id exp4) match regular expression "[snr_core.serconsole.con info] Telnet console listening to port [0-9]*."? no
expect: timed out
I also tried different escape sequences, brace, double/triple backslash etc., no luck.
Appreciate for any help