+ -
当前位置:首页 → 问答吧 → lftp同步问题

lftp同步问题

时间:2011-03-18

来源:互联网

#!/usr/bin/expect
spawn ssh-keygen -t rsa
expect ".ssh/id_rsa):"
send "\r"
expect "Overwrite (y/n)?"
send "y\r"
expect "for no passphrase):"
send "\r";
expect "same passphrase again:"
send "\r"
interact

上面是一个非常简单的expect程序,就是配置SSH密钥的。红色部分第一次运行不需要,但是以后都会询问是否覆盖。
就是说这个生成密钥,首次生成要按3下按键,以后再次生成总共要按4下。
我本来想用while true{"第三句"break;"第二句"continue}这样来做的,可是楞是找不到手册,不知道这个语法怎么写……
请问怎样可以自动判断呢?我GOOGLE了很久,有一说是expect后加入{}相当于switch?但是试过下不行。有情达人指教。

作者: 香肠超人   发布时间: 2011-03-18

已解决了,原来是
expect {
"Overwrite (y/n)?"
{send "y\r";exp_continue}
"for no passphrase):"
{send "\r"}
}
…………

作者: 香肠超人   发布时间: 2011-03-18

热门下载

更多