0

Script-1 can be run from a shell and will ask the user for 3 prompts, A, B, and C in that order. A or B will appear to the user, and C will always will appear. In other words, when Script-1 is run, the user will be prompted by question A or B. Once answered, the question C will always be prompted last.

I want to write Script-2, which will use logic to answer prompts A, B, and C automatically in Python. Pexpect seems perfect for this, however, how would one use pexpect when there are two different prompts- A or B- that could be presented to it?

Thank you.

mh00h
  • 1,824
  • 3
  • 25
  • 45

1 Answers1

-2

pexpect allows you to specify a list of prompts to match against, so it caters explicitly to your use case. Consult the docstring of pexpect.expect().

Alp
  • 2,766
  • 18
  • 13