Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 我如何编写一个脚本,允许用户输入运行所需的输入_Linux_Scripting - Fatal编程技术网

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。