如果没有在Expect中使用-re选项,则不会进行全局扩展 [英] No glob expansion without -re option in Expect
本文介绍了如果没有在Expect中使用-re选项,则不会进行全局扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#!/usr/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect -nocase "pass*" {
send "$password\r"
}
expect -nocase "password" {
send "$password\r"
}
expect eof
如何防止期望扩展pass*
中的glob *
?这只是一个例子.在我的实际代码中,我想保持全局,但是我不想在-ex
处表示精确匹配,在-re
处表示正则表达式.
How can I prevent expect to expand the glob *
in pass*
? This is just an example. In my actual code, I want to keep the glob, but I don't want to at -ex
, which stands for exact match, or -re
option for regex.
推荐答案
如果要使用全局样式匹配,请在其前使用-gl
选项:
If you want a glob-style match, use the -gl
option before it:
expect {
-gl -nocase "pass*" {
# Do something...
}
}
这篇关于如果没有在Expect中使用-re选项,则不会进行全局扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文