gpt4 book ai didi

linux - OSX shell 脚本打开新的终端窗口并运行程序

转载 作者:IT王子 更新时间:2023-10-29 01:15:24 24 4
gpt4 key购买 nike

我正在尝试编写一个简短的 shell 脚本来打开一个新的终端窗口并启动一个程序。这是我所拥有的:

osascript <<END
tell application "Terminal"
make new window
activate
set contents of window to "./hello" & return
end tell
END

execution error: Terminal got an error: AppleEvent handler failed. (-10000)

谁能告诉我怎么做?在一个完美的世界中,我还希望这个脚本可以在 Linux 上运行,所以如果有一种可移植的方法,那将是更可取的。

谢谢!

最佳答案

do script 命令在新的终端窗口中运行命令:

osascript -e 'tell app "Terminal" to do script "uptime"'

关于linux - OSX shell 脚本打开新的终端窗口并运行程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19818481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com