Get output of send command on expect

ID: get-output-of-send-command-on-expect

Get output of send command on expect by Ciro Santilli 35 Updated +Created
This pattern works well:
set prompt ">>> "
log_user 0
send "What is quantum field theory?\r"
expect -re "(.+)$prompt"
puts -nonewline [join [lrange [lmap line [split $expect_out(1,string) \n] {regsub {\r$} $line ""}] 1 end] "\n"]
Then stdout will contain only the output of the command and nothing else.

New to topics? Read the docs here!