本文介绍了从stdin读取数据时,如何防止`expect'在EOF退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行echo "passphrase" | expect expect.exp "hostname"
时,一切正常,但是expect
立即退出.
When I run echo "passphrase" | expect expect.exp "hostname"
, everything works fine, but expect
exits immediately.
#!/usr/bin/expect
set passphrase [gets stdin]
set hostname [lindex $argv 0]
spawn ssh admin@$hostname
expect "passphrase"
send "$passphrase\r"
expect "admin@$hostname"
send "clear\r"
interact
当 stdin 不是tty时,
推荐答案
interact
不起作用.您可以像主机名一样将密码作为命令行选项传递.
interact
does not work when stdin is not a tty. You can pass the password as a command line option, just like the hostname.
这篇关于从stdin读取数据时,如何防止`expect'在EOF退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!