请问expect怎样判断是否跳过下一句啊?
发表于 : 2011-03-18 16:35
#!/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?但是试过下不行。有情达人指教。
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?但是试过下不行。有情达人指教。