How to use ansible 'expect' module for multiple different responses?

前端 未结 1 573
粉色の甜心
粉色の甜心 2021-02-12 18:14

Here I am trying to test my bash script where it is prompting four times.

#!/bin/bash
date >/opt/prompt.txt
read -p \"enter one: \" one
echo $one
echo $one &g         


        
相关标签:
1条回答
  • 2021-02-12 18:55

    The reason is that the questions are interpreted as regexps. Hence you must escape characters with a special meaning in regular expressions, such as -()[]\?*. et cetara.

    Hence:

    'Enter current password for root (enter for none):'
    

    should instead be:

    'Enter current password for root \(enter for none\):'
    

    Good luck!

    0 讨论(0)
提交回复
热议问题