AppleScript 代码

发布于 2024-12-29 18:49:17 字数 364 浏览 2 评论 0原文

下面的代码在 AppleScript 中抛出语法错误(使用 Automator 时)。当代码在终端中运行时运行良好时,有什么建议可能导致它吗?

on run {input, parameters}

    tell application "Terminal"

        activate (do script with command "perl -mURI -lne 'print ((URI->new(/([\S]+) \z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt")
    end tell

    return input
end run

The below code is throwing a syntax error in AppleScript (when using Automator). Any suggestions what may be causing it as the code runs fine when running in Terminal?

on run {input, parameters}

    tell application "Terminal"

        activate (do script with command "perl -mURI -lne 'print ((URI->new(/([\S]+) \z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt")
    end tell

    return input
end run

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

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

发布评论

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

评论(1

倾城花音 2025-01-05 18:49:17

我认为您可能需要在 activate 之后换行,即

on run
    tell application "Terminal"
        activate
        do script "perl -mURI -lne 'print ((URI->new(/([\\S]+) \\z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt"
    end tell
end run

我还删除了一些多余的内容并在 OS X 10.6 上对此进行了测试。

I think you may need a line break after activate, i.e.

on run
    tell application "Terminal"
        activate
        do script "perl -mURI -lne 'print ((URI->new(/([\\S]+) \\z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt"
    end tell
end run

I've also taken out some redundant stuff and tested this on OS X 10.6.

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