[英]pexpect to expect more than one pattern
import pexpect # importing the python-expect
child = pexpect.spawn ('telnet x.x.x.x y')
child.expect ('Hit \[Enter\] to boot immediately\, or space bar for command prompt.', 300)
child.send ('\x20')
if child.expect ('loader>' or 'OK ', 10):
child.sendline ('boot -s')
What I am trying to do here is: 我在这里尝试做的是:
According to the manual : 根据手册 :
expect(pattern, timeout=-1, searchwindowsize=-1, async=False)
This seeks through the stream until a pattern is matched. 这将搜索流,直到匹配模式为止。 The pattern is overloaded and may take several types. 模式已重载,可能有几种类型。 The pattern can be a StringType, EOF, a compiled re, or a list of any of those types. 该模式可以是StringType,EOF,已编译的re或任何这些类型的列表。 Strings will be compiled to re types. 字符串将被编译为re类型。 This returns the index into the pattern list. 这会将索引返回到模式列表。 If the pattern was not a list this returns index 0 on a successful match. 如果模式不是列表,则在成功匹配时将返回索引0。
[...] [...]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.