【发布时间】:2014-06-01 16:01:21
【问题描述】:
我正在尝试编写一个自动输入密码的脚本,但似乎期望与模式不匹配。
#!/usr/bin/expect --
set pass "test"
set timeout 5
spawn sudo ssh -i ~/.ssh/id_rsa StrictHostKeyChecking=no vongrad@localhost
expect {
timeout { send_user "\nFailed to get password prompt\n"; exit 1 }
"*ssword*" {
send "$pass\r"
}
}
你有什么建议吗?
【问题讨论】:
-
由于没有人对您的原始问题发表意见,您确定期望使用像“*”这样的外壳通配符。而不是真正的常规 experssions,这将作为
.*ssword.*完成。试试看。祝你好运。