|
发表于 2009-1-25 18:54:44
|
显示全部楼层
Post by firefoxmmx;1941071
另外遇到个问题。。
具体实例发出来给大家看看。
- spawn env LANG=en_US sudo apt-get autoremove amsn
- expect "*\[Y/n\]\?*"
- send "y\n"
- exit 0
复制代码
下面是输出结果
- $ expect test1.ex
- spawn env LANG=en_US sudo apt-get autoremove amsn
- Reading package lists... Done
- Building dependency tree
- Reading state information... Done
- The following packages were automatically installed and are no longer required:
- libsnack2 amsn-data tcl8.5 tk8.5 tcl-tls
- The following packages will be REMOVED:
- amsn amsn-data libsnack2 tcl-tls tcl8.5 tk8.5
- 0 upgraded, 0 newly installed, 6 to remove and 5 not upgraded.
- After this operation, 20.5MB disk space will be freed.
- Do you want to continue [Y/n]?
复制代码
他会在这里停止掉。
我觉得是没有正确匹配的原因。(expect "Do you want to continue [Y/n]? " send "y\n" 已经用过了。。还是一样的)
我想可能是回馈信息是一段话的原因吧。一句话的可以匹配比如SUDO。。但是一段话的用正则表达式好像都没有用?~
应该怎么来匹配这个一段话中的[Y/n]呀??
似乎\r是回车啊。 |
|