Reputation: 1666
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
Reputation: 8910
Take a look at the pexpect
module: https://pexpect.readthedocs.org/en/latest/
Upvotes: 3