Linux 我如何编写一个脚本,允许用户输入运行所需的输入
例如:Linux 我如何编写一个脚本,允许用户输入运行所需的输入,linux,scripting,Linux,Scripting,例如: #!/bin/bash sudo add-apt-repository echo -n "Enter ppa here > " read $response sudo apt-get update if [ "W: GPG error: * NO_PUBKEY" = "0" ]; then echo "Enter the 16 digit key provided at the end of this error." sudo apt-add adv -
#!/bin/bash
sudo add-apt-repository
echo -n "Enter ppa here > "
read $response
sudo apt-get update
if [ "W: GPG error: * NO_PUBKEY" = "0" ]; then
echo "Enter the 16 digit key provided at the end of this error."
sudo apt-add adv --keyserver keyserver.ubuntu.com --recv-key
echo -n "Enter key here > "
read text
else
echo "Update succeeded with no errors."
fi
sudo apt-get update
但是脚本停止,因为存储库之后没有参数。如何提示用户输入回购?错误:需要一个存储库作为参数 在此处输入ppa!>
我输入了ppa,但它会继续更新而不添加ppa 无法说明它停止时没有参数的原因,但您知道您的语句
if[“W:GPG error:*no_PUBKEY”=“0”];然后
将始终返回false
并执行else
语句,是吗?另外,您的意思是它在脚本中的第一个cmd(sudo add apt repository
)之后停止吗?您的sudo
设置是否正确?对于这些项目中的任何一项,请改进Q中提供的证据,而不是在评论中进行长时间的讨论。祝你好运。错误:需要一个存储库作为参数在此处输入ppa!>我输入了ppa,但它会继续更新而不添加ppa。