- name : Execute the script and answer to question in term
expect:
command: ./"{{ script_name }}"
responses:
Question:
- ''
- ''
- ''
- 'backspace' #?
become: yes
我想使用退格键,因为我使用的脚本会提前回答,所以如果我没问题的话我只需按 Enter 键,但对于一个问题我想更改给定的答案。但到目前为止我还没有找到使用退格键的方法。有人会知道吗?
退格键的 ASCII 控制是'\b'
。这适用于双引号:
- name : Execute the script and answer to question in term
expect:
command: "echo Q"
echo: "yes"
responses:
Q: "b\bc"
例如将打印返回到标准输出1^Hc
, where ^H
确实是退格键控制。
但这可能只会向后移动光标,而不会删除前一个字符。举个例子,在我的 bash shell 中:
/bin/bash -c "echo a$'\b'"
产生a
作为输出,但是
/bin/bash -c "echo a$'\b'c"
产生c
,由于光标向后移动,因此a
被覆盖。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)