Discussion:
[Fab-user] How to properly use interactive prompts
Justin Polidora
2014-06-26 15:30:04 UTC
Permalink
Hi,

I am using Fabric 1.9 and am trying to control an interactive prompt from a
bash script. According to the Fabric documentation and GitHub tickets #741
& #1021, there is support to send interactive responses with the prompts
dictionary object. The documentation at
http://docs.fabfile.org/en/latest/usage/env.html#prompts is unclear about
describing how to use prompts in conjunction with the run() method. I am
trying to send an interactive response to a remote command.

I tried defining the prompts dictionary and using it in the following way:

def runcommand():
# I understand that the dict keys are the stdout text to expect and
the corresponding dict values are the text to send on stdin to satisfy the
waiting bash script's prompt
prompts = {"Are you sure you want to continue (yes/no)?": "yes"}
run(bash_script)

tests/test_io.py has the only code example that sort of explains the
prompts dictionary usage, but overriding the run method as described there
does not achieve the desired behavior. Shouldn't interactive prompts work
without having to override run()? I have only a beginner regarding Fabric,
but I would greatly appreciate any guidance in this matter.

Thank you,
Justin
Brandon Whaley
2014-06-27 00:51:03 UTC
Permalink
Hi Justin,

In your example code, you're setting a local variable named prompts. Try
setting env.prompts instead.
Post by Justin Polidora
Hi,
I am using Fabric 1.9 and am trying to control an interactive prompt from
a bash script. According to the Fabric documentation and GitHub tickets
#741 & #1021, there is support to send interactive responses with the
prompts dictionary object. The documentation at
http://docs.fabfile.org/en/latest/usage/env.html#prompts is unclear about
describing how to use prompts in conjunction with the run() method. I am
trying to send an interactive response to a remote command.
# I understand that the dict keys are the stdout text to expect and
the corresponding dict values are the text to send on stdin to satisfy the
waiting bash script's prompt
prompts = {"Are you sure you want to continue (yes/no)?": "yes"}
run(bash_script)
tests/test_io.py has the only code example that sort of explains the
prompts dictionary usage, but overriding the run method as described there
does not achieve the desired behavior. Shouldn't interactive prompts work
without having to override run()? I have only a beginner regarding Fabric,
but I would greatly appreciate any guidance in this matter.
Thank you,
Justin
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...