AppleScript做脚本总是Echos命令

发布于 2025-02-03 03:48:06 字数 826 浏览 5 评论 0原文

on run argv
    set scpt to first item of argv
    tell application "Terminal"
        do script "bash " & scpt
        activate
    end tell
end run

问题是我告诉它要执行什么脚本命令,它总是首先在终端中打印该命令。我不希望这种回声行为如何使用AppleScript禁用它。

编辑1:这是纯Applescript逻辑的一个很好的例子,输出看起来很恐怖。现在,尽管您能够进行设置 +v bash命令以关闭回声,请说echo foo是一个非常长的命令,清除屏幕会引起闪烁。我问如何启用回声或set +v而不会引起回声开始?

tell application "Terminal"
    set a to do script ""
    activate
    do script "echo foo" in a
    do script "echo ardvark" in a
end tell

编辑2:我尝试使用清晰的bash中的set +v,但没有维护

tell application "Terminal"
    set a to do script ""
    activate
    do script "bash -c \"set +v\" ; clear" in a
    do script "echo foo" in a
    do script "echo hello world" in a
end tell
on run argv
    set scpt to first item of argv
    tell application "Terminal"
        do script "bash " & scpt
        activate
    end tell
end run

the issue is no matter what script command I tell it to do it always prints that command in terminal first. I don't want this echo behavior how do I disable it with using AppleScript.

Edit 1: this is a good example of pure AppleScript logic and the output looks horrible. Now while your able to do set +v bash command to turn the echo off let's say echo foo was a really long command clearing the screen causes a flicker. I am asking how to enable echo off or set +v without causing an echo to begin with?

tell application "Terminal"
    set a to do script ""
    activate
    do script "echo foo" in a
    do script "echo ardvark" in a
end tell

Edit 2: I tried using the set +v from bash with clear and it wasn't maintained

tell application "Terminal"
    set a to do script ""
    activate
    do script "bash -c \"set +v\" ; clear" in a
    do script "echo foo" in a
    do script "echo hello world" in a
end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终弃我 2025-02-10 03:48:06

不确定我确切地理解您的问题/需求,但要从我能告诉我的需要的内容相反,因此请阅读您的问题解决了我的问题。

# launch application
tell application "Terminal"
    set a to do script "/path/script.sh"
    activate
end tell

输出与终端相呼应,

# launch application
tell application "Terminal"
    activate
    do shell script "/path/script.sh"
end tell

没有输出回声

Not sure that I understand your question/need exactly but from what I can tell I had the opposite need and so, reading your question solved mine.

# launch application
tell application "Terminal"
    set a to do script "/path/script.sh"
    activate
end tell

Output is echoed to terminal

# launch application
tell application "Terminal"
    activate
    do shell script "/path/script.sh"
end tell

No output is echoed to terminal

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文