【问题标题】:Automating Enter keypress not working for Linux Mint 15自动输入按键不适用于 Linux Mint 15
【发布时间】:2013-05-28 00:16:14
【问题描述】:

我已经为 Linux Mint 14 的用户制作了这个安装后脚本(也可在 Ubuntu 12.10 上使用),现在我正在为 Linux Mint 15 和 'echo -ne "\n" | 测试它。 sudo add-apt-repository ppa:some-ppa-to-add' 命令不适用于 Linux Mint 15,但仍适用于 Mint 14。我想为新版本的 Linux Mint 更新此脚本。

这是我的安装后 scipt 的链接:The Minty Developer

Mint 14 的输出如下所示:

$ echo -ne "\n" | sudo add-apt-repository ppa:apt-fast/stable
You are about to add the following PPA to your system:
 This PPA contains tested (stable) builds of apt-fast.
 More info: https://launchpad.net/~apt-fast/+archive/stable
gpg: keyring `/tmp/tmpddxueh/secring.gpg' created
gpg: requesting key CA8DA16B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpddxueh/trustdb.gpg: trustdb created
gpg: key CA8DA16B: public key "Launchpad PPA for apt-fast" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

这是 Mint 15 的输出:

$ echo -ne "\n" | sudo add-apt-repository ppa:apt-fast/stable
You are about to add the following PPA to your system:
This PPA contains tested (stable) builds of apt-fast.
More info: https://launchpad.net/~apt-fast/+archive/stable

就是这样。什么都没发生。 我也测试过只做 echo | ppa:some-ppa-to-add 和结果是一样的。

谁能帮我弄清楚如何使这行代码/命令工作,以便那些有兴趣在新版本的系统中使用它的人可以更新脚本?

谢谢。

【问题讨论】:

    标签: linux bash shell terminal automation


    【解决方案1】:

    您可以使用add-apt-repository --yes,但回答该问题会覆盖系统范围的安全策略。

    你没有说用户是谁;如果您的脚本为我这样做,我会很生气,但我不是典型的最终用户。我刚刚看了你的剧本,一般来说它是对话的。如果它说类似

    我将从相当可靠的来源添加这些软件包并进行设置,以便它们能够自动更新等等。

    这样会更有礼貌。

    已添加

    add-apt-repository 中有一个未记录的功能,可让您以编程方式覆盖问题:

    if (sys.stdin.isatty() and
      not "FORCE_ADD_APT_REPOSITORY" in os.environ):
        if options.remove:
            print(_("Press [ENTER] to continue or ctrl-c to cancel removing it"))
                else:
            print(_("Press [ENTER] to continue or ctrl-c to cancel adding it"))
            sys.stdin.readline()
    

    因此是 bash 序列

    export FORCE_ADD_APT_REPOSITORY=force
    sudo add-apt-repository ppa:webupd8team/sublime-text-2
    sudo add-apt-repository ...
    

    应该停止提问。它仍然会显示噪音

    You are about to add the following PPA to your system:
     Sublime Text 2 packages - the .deb will automatically download the 
     latest build from http://www.sublimetext.com/dev or beta from
     http://www.sublimetext.com/2 (Adobe Flash Player installer - style).
    
    More info and feedback: 
    http://www.webupd8.org/2011/03/sublime-text-2-ubuntu-ppa.html
    http://www.webupd8.org/2012/03/sublime-text-2-ppa-separate-development.html
     More info: https://launchpad.net/~webupd8team/+archive/sublime-text-2
    

    但这是放在标准输出上的,所以应该能够发送到> /dev/null,但错误仍然出现在标准错误上。

    【讨论】:

    • 谢谢你,我会测试它,我一定会在脚本中添加类似的东西:)
    • 我开始浏览 apt-* 脚本套件,--yes 标志文档仅适用于一个关于修复lp: 存储库的问题。我还没有找到它要求添加钥匙的地方,但我的意志很坚强......
    • @VilliMagg 我找到了,请参阅添加
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2014-07-04
    • 2019-04-21
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    相关资源
    最近更新 更多