expect怎么加上判断语句

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
木泥黑
帖子: 1339
注册时间: 2008-10-18 12:41

expect怎么加上判断语句

#1

帖子 木泥黑 » 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,就不执行后面的步骤
头像
木泥黑
帖子: 1339
注册时间: 2008-10-18 12:41

Re: expect怎么加上判断语句

#2

帖子 木泥黑 » 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
poseidon88
帖子: 1
注册时间: 2011-11-11 11:08

Re: expect怎么加上判断语句

#3

帖子 poseidon88 » 2011-11-11 11:10

:em09 楼主威武
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: expect怎么加上判断语句

#4

帖子 naturalaw » 2011-11-27 18:48

图片
  • The eternal law
头像
daemon11
帖子: 60
注册时间: 2011-11-16 17:51

Re: expect怎么加上判断语句

#5

帖子 daemon11 » 2011-11-27 19:38

木泥黑 写了::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 楼主能解释一下这个是干什么的吗?
回复