【问题标题】:How to start shell script with arguments in new terminal window如何在新的终端窗口中使用参数启动 shell 脚本
【发布时间】:2017-12-26 08:29:12
【问题描述】:

我尝试从 mac osx 在新的终端窗口中运行 shell 脚本。我像这样使用open cmd,它工作正常 open -a Terminal script.sh

我的问题是我必须在我的 shell 中传递参数。我试过了 open -a Terminal script.sh arg open -a Terminal script.sh --args arg open -a Terminal --args script.sh arg open -a Terminal "script.sh arg"

但没有任何工作! 你知道怎么做吗?

【问题讨论】:

  • 你找到解决办法了吗?

标签: macos shell terminal arguments


【解决方案1】:

我发现了一些东西。我不喜欢这个,但它有效:

osascript -e 'tell application "Terminal" to do script "cd ${Dir} && ./script.sh ${arg}"'

【讨论】:

    【解决方案2】:

    您是否在终端尝试过sudo bash /path/to/script -option1 -option2(如果您的脚本需要sudo)或bash /path/to/script -option1 -option2(如果不需要sudo)?

    【讨论】:

    • 您好,感谢您的回答。此命令有效,但我需要在新终端中打开脚本,而不是在当前终端中。我认为 Applescript 可以完成这项工作,但执行起来很慢。
    猜你喜欢
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 2017-01-17
    • 2020-06-18
    • 2018-12-12
    相关资源
    最近更新 更多