expect output only stdout of the command and nothing else

Viewed 10127

How to write expect script which executes command and prints just the command's output?

I've tried various things but none works, e.g.

#!/usr/bin/expect
log_user 0
spawn bash
send "echo 1\r"
log_user 1
expect "1"
log_user 0
send "exit\r"
expect eof

Gives in output:

echo 1

While I need just "1" . I hope somebody knows simple solution how to fix my example

2 Answers
Related