对 'any key to continue' 的编程响应
Programing response to 'any key to continue'
场景: 每当我在我的机器上新安装 Linux 时,我都会安装大量的存储库和第 3 方程序,以及过程(包括配置) 往往需要半天时间。我使用 Advanced Package Tool
安装这些程序,我正在尝试自动执行此过程。
问题: APT 通常会提示用户输入按键 'Y',以确认安装,我想知道如何使用 Bash 脚本来自动执行此按键操作,以便脚本可以在没有任何人工交互的情况下继续安装。
按键示例:
0 to upgrade, 2 to newly install, 0 to remove and 8 not to upgrade.
Need to get 202 kB of archives.
After this operation, 736 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
规范: 我考虑过将所有 apt-get
安装压缩到一个 apt-get
系统调用中(这是可能的),但是我想要程序通过监控return个代码来记录每次安装的成功。
我应该指定;按键将在执行系统调用期间发生:apt-get install **application**
,我不确定是否其他脚本语言(例如 Ruby
或 Python
可能不会更适合此任务。
提前致谢。
我想你可以直接使用
yes | sudo apt-get install ...
当然,您需要设置它,这样您就不必输入密码了。
apt-get
非常明确地有一个 -y
选项允许您绕过交互式提示。
场景: 每当我在我的机器上新安装 Linux 时,我都会安装大量的存储库和第 3 方程序,以及过程(包括配置) 往往需要半天时间。我使用 Advanced Package Tool
安装这些程序,我正在尝试自动执行此过程。
问题: APT 通常会提示用户输入按键 'Y',以确认安装,我想知道如何使用 Bash 脚本来自动执行此按键操作,以便脚本可以在没有任何人工交互的情况下继续安装。
按键示例:
0 to upgrade, 2 to newly install, 0 to remove and 8 not to upgrade. Need to get 202 kB of archives. After this operation, 736 kB of additional disk space will be used. Do you want to continue? [Y/n] y
规范: 我考虑过将所有 apt-get
安装压缩到一个 apt-get
系统调用中(这是可能的),但是我想要程序通过监控return个代码来记录每次安装的成功。
我应该指定;按键将在执行系统调用期间发生:apt-get install **application**
,我不确定是否其他脚本语言(例如 Ruby
或 Python
可能不会更适合此任务。
提前致谢。
我想你可以直接使用
yes | sudo apt-get install ...
当然,您需要设置它,这样您就不必输入密码了。
apt-get
非常明确地有一个 -y
选项允许您绕过交互式提示。