Reputation: 23
I don't seem to be getting the expected workings. I can't seem to actually catch the prompt.
Here is what I have:
with settings(hide('commands', 'warnings') , warn_only=True):
prompts = expect('Are you sure you want to perform this operation? [Y/N]:', 'N')
with expecting(prompts):
run(sudo("/something.sh apply /some.file" , user="someuser"))
I'm pretty sure I'm doing something wrong.
Upvotes: 2
Views: 572
Reputation: 3218
I have edited your code with some minor things:
expecting
requires a listYou have to escape regexp symbols, such as []
with a slash \[
or just make the 'expectation' shorter:
prompts = []
prompts += expect('Are you sure.*', 'N')
with expecting(prompts):
sudo("/something.sh apply /some.file" , user="someuser")
Also, perhaps you should not hide('commands')
, depending on what prompt something.sh
uses.
Upvotes: 0