加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 23:09:17 所属栏目:Linux 来源:网络整理
导读:我正在尝试编写一个简短的 shell脚本来打开一个新的终端窗口并启动一个程序.这是我有的: osascript ENDtell application "Terminal" make new window activate set contents of window to "./hello" returnend tellEND execution error: Terminal got an er
我正在尝试编写一个简短的 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上运行,所以如果有一个可移植的方法,那就更好了.

谢谢!

解决方法

这样的事情:

osascript<<EOF
tell application "System Events"
  tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
  activate
  do script with command "./hello" in window 1
end tell
EOF

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读