如何使用 commhe 和 line 为 whiptail 提供输入
how to provide an input for whiptail using commhe and line
因此,我必须设置多个服务器,每个服务器都需要 mysql-server。我决定编写一个 shell 脚本来输入 whiptail ,这需要用户输入密码。我写了 bash 脚本,但是当它到达 whiptail 页面时它只是没有响应,有人可以帮我解决这个问题吗?谢谢
#!/bin/bash
sudo apt-get install mysql-server <<< "yes
mypassword
"
首先,当 sudo apt-get 询问是否安装时,它提供 yes,但是当涉及 whiptail 时,它不提供任何输入,因为它应该是 mypassword
您可以像这样 运行 apt-get install
在安装过程中跳过提示,而不是向 whiptail 提供输入:
DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server
如果您还想提供 root 密码,可以这样做:
export DEBIAN_FRONTEND="noninteractive"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password myrootpw"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password myrootpw"
sudo apt-get install -y mysql-server
注意不要意外泄露您的 root 密码(即确保它不会出现在您的历史记录中,安全地删除任何包含它的脚本文件,我相信还有其他的)。
我找到了这个信息here。
因此,我必须设置多个服务器,每个服务器都需要 mysql-server。我决定编写一个 shell 脚本来输入 whiptail ,这需要用户输入密码。我写了 bash 脚本,但是当它到达 whiptail 页面时它只是没有响应,有人可以帮我解决这个问题吗?谢谢
#!/bin/bash
sudo apt-get install mysql-server <<< "yes
mypassword
"
首先,当 sudo apt-get 询问是否安装时,它提供 yes,但是当涉及 whiptail 时,它不提供任何输入,因为它应该是 mypassword
您可以像这样 运行 apt-get install
在安装过程中跳过提示,而不是向 whiptail 提供输入:
DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server
如果您还想提供 root 密码,可以这样做:
export DEBIAN_FRONTEND="noninteractive"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password myrootpw"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password myrootpw"
sudo apt-get install -y mysql-server
注意不要意外泄露您的 root 密码(即确保它不会出现在您的历史记录中,安全地删除任何包含它的脚本文件,我相信还有其他的)。
我找到了这个信息here。