Python Forum

Full Version: Pexpect module first step
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am reading up/watching videos and am taking my first baby steps with pexpect.
I expected (wrongly) that the sequence below would work.
That is I would spawn a process to ssh to the defined host.
Is "expect" really not defined within the said module?

Appreciate any help....


blah@xxxxx3:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pexpect
>>> p = expect.spawn("ssh xxx-xxx-7")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'expect' is not defined
>>>
it need to be pexpect.spawn() - there is missing p at the start