隐藏期望的输出 [英] Hide output from expect

查看:405
本文介绍了隐藏期望的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是期望脚本的一部分

#/usr/bin/expect 

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

# do some thing
# ...

它从kwalletcli读取密码,并存储在变量passwd中.因此,我可以使用此passwd连接到服务器.

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

但是,kwalletcli的输出是通过Expect传递并在控制台上显示的.我怎么藏起来.

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

推荐答案

尝试添加

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

这篇关于隐藏期望的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆