【问题标题】:Start a new mac terminal window from a groovy script从 groovy 脚本启动一个新的 mac 终端窗口
【发布时间】:2016-06-27 21:12:37
【问题描述】:

而像这样在 Groovy 脚本文件中执行命令:

println "ls".execute().text

工作正常,这个命令:

println "osascript -e 'tell application \"Terminal\" to do script \"ls\"'".execute().text

不运行!知道如何让 Groovy 启动一个带有运行命令的新终端窗口吗?谢谢。

【问题讨论】:

    标签: groovy command-line terminal


    【解决方案1】:

    你可以这样做:

    def txt = ['/bin/bash', '-c', /osascript -e 'tell application "Terminal" to do script "ls"'/].execute().text
    println txt
    

    但我认为它不会按照您的意愿进行操作,因为它会打印以下内容:

    tab 1 of window id 38373
    

    【讨论】:

    • 好吧,第一部分做了我想做的事!这种印刷的副作用是良性的。将等待看看是否有更好的解决方案;否则你会的。谢谢。
    猜你喜欢
    • 2018-12-12
    • 2020-06-18
    • 2010-09-24
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    相关资源
    最近更新 更多