如何在Linux中对两个提示进行输入

问题描述 投票:0回答:1

我有一个来自供应商的 shell 脚本,在 Linux 服务器上运行时需要两次提示。有人可以帮助我们如何在单个命令中提供两次提示输入以实现自动化目的。 这里的o和1是提示。

sh Contrast-3.11.6.sh 
Unpacking JRE ...
Starting Installer ...
Acquire Linux root privilege
Root privileges could not be acquired. The Contrast server will not be
installed as a Linux service that starts automatically on system boot and
database backups will need to be manually setup.
This will install Contrast Enterprise On-Premises on your computer.
OK [o, Enter], Cancel [c]
o
A previous installation has been detected. Do you wish to update that installation?
Yes, update the existing installation [1, Enter]
No, install into a different directory [2]
1

谢谢, 阿尔皮特

linux shell sh
1个回答
0
投票
echo -e "o\n1" | ./your_script.sh

-e 标志可以解释反斜杠转义(例如 用于换行)

您可以使用简单的脚本模拟上述行为,并确认它是否适用于您的环境

© www.soinside.com 2019 - 2024. All rights reserved.