【问题标题】:Bash - open a new terminal tab then execute commandBash - 打开一个新的终端选项卡然后执行命令
【发布时间】:2017-09-17 04:06:14
【问题描述】:

以下 bash 脚本假设打开 2 个新的终端选项卡,然后执行相应的命令:

mate-terminal --tab -e "cd ~/ece344/root; sys161 -w kernel" --tab -e "cd ~/ece344/root; cs161-gdb kernel"

脚本确实打开了 2 个新选项卡,但是两个选项卡都显示以下错误:

There was an error creating the child process for this terminal
Failed to execute child process "cd" (No such file or directory)

附言。答案应该适用于mate-terminal

【问题讨论】:

    标签: bash terminal


    【解决方案1】:

    我没有安装伴侣,但我会尝试:

    mate-terminal --tab -e "/bin/bash -c 'cd ~/ece344/root; sys161 -w kernel'" --tab -e "/bin/bash -c 'cd ~/ece344/root; cs161-gdb kernel'"
    

    这个想法是“-e”想要执行一个可能在窗​​口内运行的命令而不是默认shell,所以从错误中我了解到“cd”不是预期位置的真实程序(因为'cd' 在 PATH 中应该不是问题。 所以我的例子会提供一个完整的路径到一个shell“/bin/bash”,然后它会执行你想要的命令。

    【讨论】:

    • 除了现在的 "Failed to execute child process "bin/bash" (No such file or directory)" 之外会产生相同的错误
    • 该错误消息表明您写的是-e "bin/bash ...",而不是-e "/bin/bash ..."
    • 就我而言,我想让终端保持打开状态...stackoverflow.com/questions/25351454/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2014-10-10
    相关资源
    最近更新 更多