【发布时间】:2017-09-20 18:54:08
【问题描述】:
我编写了一个 shell 脚本来安装软件。但它有交互式控制台。说,输入是/否。
命令:sudo ./downloaded_software.run
Shell 脚本将包含上述命令 (test.sh)
Response of a command:
----------------------------------------------------------------------------
Welcome to the Setup Wizard.
----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.
Core Files [y/N] :
像这样,要处理三个交互式响应(Y 、 Y 并按 [Enter])。我该怎么做?
【问题讨论】:
-
我没有听懂你的问题,你想由用户创建交互式软件安装吗?你想知道如何在 Linux ubuntu 中做到这一点?
-
描述“捕获”是什么意思。
-
@LethalProgrammer:在手动过程中,我可以看到这些交互式提示。我想知道如何处理它(自动/通过 shell 脚本)。
-
@NoufalIbrahim:我的意思是上面粘贴的响应中的“捕获”。我的想法是捕获该响应并传递所需的键(Y、N、'[ENTER]')。
-
而在自动方式中它不同。我想你安装 *.deb 包。在 debian 系统中,您可以编写一个脚本,在其中执行
sudo apt get install yoursoftware它将安装。如果您想自动化安装脚本,您可以将 shell 脚本作为服务脚本,在您的应用程序进程启动并运行的地方,它可以触发安装脚本。