Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pexpect module first step
#1
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
>>>
Reply
#2
it need to be pexpect.spawn() - there is missing p at the start
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading and storing a line of output from pexpect child eagerissac 1 4,146 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  Import a module one step back of the path prathampatel9 1 1,036 Sep-21-2022, 01:34 PM
Last Post: snippsat
  Use pexpect to send user input alisha17 0 1,827 May-10-2022, 02:44 AM
Last Post: alisha17
  Not able to read the text using pexpect/expect Bipinjohnson 7 3,940 Jan-10-2022, 11:21 AM
Last Post: Bipinjohnson
  Sudden Problem with pexpect gw1500se 3 2,324 Nov-19-2021, 11:21 PM
Last Post: bowlofred
  How to use pexpect in python? tiho_bg 1 1,489 Oct-30-2021, 02:50 PM
Last Post: Yoriz
  Pexpect timesout before executing whole output eagerissac 0 1,453 Jun-23-2021, 03:30 AM
Last Post: eagerissac
  pexpect startup help korenron 2 3,433 Apr-27-2021, 07:23 AM
Last Post: korenron
  Problem with pexpect.exception.TimeOUT korenron 0 3,242 Apr-12-2021, 03:25 PM
Last Post: korenron
  Request help on pexpect rsurathu 4 5,721 Jul-19-2020, 03:35 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020