【发布时间】:2017-02-20 00:30:52
【问题描述】:
我正在使用 pexpect 在 CentOS 上自动配置应用程序。我的提示是换行如下,
Please enter command below.
在下一行(空白/新行),我需要输入必要的命令,
我尝试了几件事来匹配 r'\b below.\b' 以检查新行 r'\r\n(\w+)' 、空格 (\s) 等等,但没有一个与 expect 提示符匹配。
例如。
child.sendline('a')
child.expect([pexpect.TIMEOUT,r'\b below.\b'])
print child.before
如果有人可以为此提供任何建议,那将是很大的帮助..
【问题讨论】:
-
试试
r'.*\b below\.\b'和expect -
或
.expect(r'Please enter command below\.\r\n') -
pexpect读取流并且无法检查字符的序列,您必须使用expect。
标签: regex python-2.7 pexpect