如何在新的终端窗口中使用参数启动shell脚本

时间:2017-07-20 14:49:09

标签: macos shell terminal arguments

我试图从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"

但没有任何工作! 你知道这样做的方法吗?

2 个答案:

答案 0 :(得分:0)

我找到了一些东西。我不喜欢这样但它有效:

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

答案 1 :(得分:0)

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