Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide output from expect

Tags:

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.

like image 270
yegong Avatar asked Jan 30 '13 10:01

yegong


2 Answers

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 
like image 111
glenn jackman Avatar answered Nov 07 '22 04:11

glenn jackman


using this command:

exec >log 2>&1 

you can forward your output to a file or you can pass it to dev/null

like image 45
Hamid Reza Moradi Avatar answered Nov 07 '22 02:11

Hamid Reza Moradi