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. Strings will be compiled to re types. This returns the index into the pattern list. If the pattern was not a list this returns index 0 on a successful match.
[...]