7

I would like to generate Python Expect (pexpect) code automatically, does something like autoexpect exist for pexpect?

Jed Daniels
  • 24,376
  • 5
  • 24
  • 24

2 Answers2

5

I have written one:

https://github.com/ianmiell/autopexpect

which works in very basic form. Please contribute if you can!

Use it much the same way as autoexpect:

./autoexpect
[your session]
[exit session]
./script.py

As with autoexpect, you may need to fiddle with the produced script.

ianmiell
  • 151
  • 1
  • 4
  • @ianmiell Your question showed up in the review queue, probably because it's mostly a link-only answer. If you could provide some context on how to use it, or how it works, it would greatly improve the value of your answer. Please consider doing so, otherwise I'm afraid your answer might get deleted, even though it might be useful ;) – Bono Apr 24 '16 at 10:45
  • Awesome! Have you tested it with sshing somewhere and doing some things yet? – Jed Daniels Apr 25 '16 at 19:51
  • Hi Jed, no I haven't - but feel free to test and raise an issue on GH if necessary. – ianmiell Apr 27 '16 at 13:45
4

Not really, AFAIK, but you could use expy AKA expectpy, rather than pexpect, if you depend on autoexpect's functionality. There's nothing conceptually standing in the way of implementing a pyautoexpect -- it's just that, as far as I know, nobody's taken the trouble of doing it (since I've never felt a need for autoexpect myself, I'm not really surprised;-).

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395