Hide output from expect

yegong picture yegong · Jan 30, 2013 · Viewed 27.6k times · Source

Here's part of an expect script

#/usr/bin/expect 

spawn -noecho kwalletcli -f Passwords -e keyofmypassword
expect ".*"
set passwd $expect_out(buffer)

# do some thing
# ...

It read password from kwalletcli, and store in variable passwd. So I can connect to the servers with this passwd.

However, the output of kwalletcli is pass through expect and show on console. How can I hide that.

Answer

glenn jackman picture glenn jackman · Feb 1, 2013

Try adding

log_user 0

to your script. That should turn off the display to stdout.

If you want to turn it on again for the "do some thing" part of the program, re-enable it

log_user 1