2016-03-03 46 views
0

例子:我如何写一个脚本,允许用户输入的输入来运行它

#!/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 

但脚本停止,因为库后,无参数。如何提示用户输入回购?

+0

不能说为什么它停止与无参数,但你意识到你的语句'if [“W:GPG错误:* NO_PUBKEY”=“0”];那么''将总是返回'false'并执行'else'语句,是吗?另外,你的意思是你的脚本('sudo add-apt-repository')中的第一个cmd后停止吗?你的'sudo'设置是否正确?对于这些项目中的任何一个,请改进Q中提供的证据,而不是在评论中进行漫长的讨论。祝你好运。 – shellter

回答

0

错误:需要存储库作为参数 在此输入ppa! > 我输入一个ppa,但它会继续更新而不添加ppa。

+0

错误:需要存储库作为参数 在此输入ppa! > 我输入一个ppa,但它会继续更新而不添加ppa。 –

相关问题