“期望”只能回答一些问题吗?

时间:2014-10-05 16:52:26

标签: linux bash expect

此脚本的问题在于,如果有任何yum更新,则它仍然会退出。

#!/usr/bin/expect

spawn su -c "yum update"
expect "Password: "
send "secret\n"
expect eof
exit

我希望能够在那种情况下回答是或否。

问题

是否可以让except回答密码问题,然后让其余问题保持互动?

1 个答案:

答案 0 :(得分:1)

例如:

#!/usr/bin/expect

spawn su -c "yum update"
expect "Password: "
send "secret\n"
interact
exit