aemdy aemdy - 1 month ago 31
Python Question

How to answer to prompts automatically with python fabric?

I want to run a command which prompts me to enter yes/no or y/n or whatever. If I just run the command

then it stops and asks me for input. When I type what is needed, script continues to work. How can I automatically respond to the prompt?



pip install fexpect

from ilogue.fexpect import expect, expecting, run 

prompts = []
prompts += expect('What is your name?','John')
prompts += expect('Are you at stackoverflow?','Yes')

with expecting(prompts):

Fexpect adds answering to prompts to fabric with use of pexpect