Reputation: 124
I have created a fabfile with multiple hosts.
I am automating my experiment. When i run the command "sudo adduser --ingroup hadoop hduser" it will ask for the following.
I would like to pass all this information as part of script without prompting user. How can i do this ?
Thanks
Navaz
Upvotes: 1
Views: 1377
Reputation: 3218
Another option is to use fexpect
, an extension of fabric that enables you to respond to prompts:
from ilogue.fexpect import expect, expecting, run
prompts = []
prompts += expect('What is your full name?','John Doe')
prompts += expect('is this information Correct? Y/N','Y')
with expecting(prompts):
sudo('adduser --ingroup hadoop hduser')
Upvotes: 1
Reputation: 335
Why didn't you just use pipes?
For example, for an automated auto accept, just use yes, that just outputs a neverending stream of y.
yes | rm *.txt
in your case:
local('echo 'your_super_password\n' | sudo adduser --ingroup hadoop hduser')
Upvotes: 1