Is it possible to "wait" for different answers from an expect
command at the same time?
E.g: child.expect('first', 'second')
And if YES, how can differentiate which one has triggered it?
Yes, you can do it like:
i = child.expect(['first', 'second'])
The expect() method returns the index of the pattern that was matched. So in your example:
if i == 0:
# do something with 'first' match
else: # i == 1
# do something with 'second' match
For more: http://pexpect.readthedocs.org/en/stable/overview.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With