分页: 1 / 1

expect怎么加上判断语句

发表于 : 2009-11-18 17:21
木泥黑

代码: 全选

#!/usr/bin/expect -f
spawn sudo chmod -R  u+s /Applications/Utilities/Adobe\ AIR\ Application\ Installer.app
set timeout 20
expect "Password:"
send "54321\r"
expect eof"
#end
如果检测到Password:就会自动输入密码

但是如果屏幕没有Password就会出现错误提示

代码: 全选

send: spawn id exp7 not open
    while executing
"send "54321\r""
    (file "/Users/onlinenmg/Desktop/234.sh" line 7)
怎么加上判断语句,如果没有Password,就不执行后面的步骤

Re: expect怎么加上判断语句

发表于 : 2009-11-18 18:05
木泥黑
:em11

代码: 全选

#!/usr/bin/expect -f
spawn sudo chmod -R  u+s /Applications/Utilities/Adobe\ AIR\ Application\ Installer.app
set timeout 20
expect {
"Password:" { send "54321\r"; exp_continue}
}
exit
#end

Re: expect怎么加上判断语句

发表于 : 2011-11-11 11:10
poseidon88
:em09 楼主威武

Re: expect怎么加上判断语句

发表于 : 2011-11-27 18:48
naturalaw
图片

Re: expect怎么加上判断语句

发表于 : 2011-11-27 19:38
daemon11
木泥黑 写了::em11

代码: 全选

#!/usr/bin/expect -f
spawn sudo chmod -R  u+s /Applications/Utilities/Adobe\ AIR\ Application\ Installer.app
set timeout 20
expect {
"Password:" { send "54321\r"; exp_continue}
}
exit
#end
:em20 楼主能解释一下这个是干什么的吗?