如何自动响应Linux Bash脚本中的提示? [英] How can I respond to prompts in a Linux Bash script automatically?

查看:102
本文介绍了如何自动响应Linux Bash脚本中的提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个脚本(我无法对其进行编辑),并且存在三个是/否问题.我如何自动回答这些问题?我需要按顺序回答是,是,否.

I am running a script (I can't edit it), and there are three yes/no questions. How can I automatically respond to these questions? I need to answer yes, yes, no (in that order).

推荐答案

尝试一下:

echo -e "yes\nyes\nno" | /path/to/your/script

来自help echo:

-e:启用对以下反斜杠转义的解释

-e: enable interpretation of the following backslash escapes

这篇关于如何自动响应Linux Bash脚本中的提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆