【问题标题】:Osascript to Bash CommandOsascript 到 Bash 命令
【发布时间】:2014-06-19 20:16:55
【问题描述】:

这很简单。就是搞不定。

我正在制作一个 alfredworkflow,我想在其中获取一个 URL,然后在终端中 curl / wget(程序无关紧要)。如果我可以在后台执行此操作,那就太好了,但如果它需要打开终端,我可以忍受。

到目前为止我所拥有的:

tell application "Google Chrome"
  set theURL to URL of active tab of window 1
end tell

tell application "Terminal"
    activate
    do script "echo "${theURL}
end tell 

【问题讨论】:

  • 这不是AppleScript,不是ActionScript吗?

标签: bash shell terminal applescript alfred


【解决方案1】:

试试这个:

tell application "Google Chrome"
    set theURL to URL of active tab of window 1
end tell
do shell script "curl --remote-name '" & theURL & "'"

AppleScript 中的字符串连接运算符是&,您不要将${...} 放在变量周围。

这将在后台运行curl,无需打开终端。 --remote-name 选项告诉它将结果写入一个文件,该文件的名称类似于 URL 的文件名部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    • 2019-05-16
    • 2023-03-21
    • 1970-01-01
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多