Jack Pettersson
Jack Pettersson

Reputation: 1666

Python: Answer terminal prompt

Anyone out there know if there is any way to answer to a terminal prompt from python? In particular what i'm trying to achieve is creating a user using "adduser" and answer to all the prompts.

What i've tried so far is simply using os.system(), but it only executes commands once the previous one finishes (I.E it can't be used to answer prompts).

Upvotes: 2

Views: 425

Answers (1)

Max Noel
Max Noel

Reputation: 8910

Take a look at the pexpect module: https://pexpect.readthedocs.org/en/latest/

Upvotes: 3

Related Questions