I would like to automate the response for some question prompted by some programs, like mysql prompting for a password, or apt asking for a 'yes' or ... when I want to rebuild my haystack index with a ./manage.py rebuild_index.
For MySQL, I can use the --password= switch, and I'm sure that apt has a 'quiet' like option. But how can I pass the response to other programs ?
Use the input() function to get Python user input from keyboard. Press the enter key after entering the value. The program waits for user input indefinetly, there is no timeout.
raw_input() in Python 2 reads input from the keyboard and returns it.
If you are looking for a user to confirm an operation, use the confrim method.
if fabric.contrib.console.confirm("You tests failed do you want to continue?"): #continue processing
Or if you are looking for a way to get input from the user, use the prompt method.
password = fabric.operations.prompt("What is your password?")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With