期望工具和逻辑或
expect tool and logical OR
我对我的脚本使用 expect
命令。我有几个不同的提示,我需要 OR 表达式。
有没有可能做这样的事情?
expect {
'Hello. Press y for YES' *OR* 'Welcome again. Press y' {send -- "y\r" }
}
预计已经有或内置,例如:
expect {
"Hello. Press y for YES" {send -- "y\r"}
"Welcome again. Press y" {send -- "y\r"}
}
如果动作太大,可以放在函数中。但是,如果您愿意,可以使用正则表达式 a|b:
expect -re "Hello. Press y for YES|Welcome again. Press y" {send "y\r"}
我对我的脚本使用 expect
命令。我有几个不同的提示,我需要 OR 表达式。
有没有可能做这样的事情?
expect {
'Hello. Press y for YES' *OR* 'Welcome again. Press y' {send -- "y\r" }
}
预计已经有或内置,例如:
expect {
"Hello. Press y for YES" {send -- "y\r"}
"Welcome again. Press y" {send -- "y\r"}
}
如果动作太大,可以放在函数中。但是,如果您愿意,可以使用正则表达式 a|b:
expect -re "Hello. Press y for YES|Welcome again. Press y" {send "y\r"}