【问题标题】:applescript does not run from terminalapplescript 不从终端运行
【发布时间】:2017-08-26 12:55:44
【问题描述】:

为什么我的applescript不能从终端运行我可以从编辑器成功运行它

我运行命令

/usr/bin/osascript -e my_script.scpt

我得到错误

0:12: 语法错误:未知标记不能跟在这个标识符之后。 (-2740)

我的脚本

set volume 2
set x to 0
open location "spotify:user:wunspe:playlist:meininki"
tell application "Spotify"
    set the sound volume to 0
    play
    repeat 10 times
        if sound volume is less than 70 then
            set sound volume to (sound volume + 10)
            set x to (x + 9)
            set volume output volume x without output muted --100%

            delay 3
        end if
    end repeat



end tell

【问题讨论】:

    标签: macos shell terminal applescript


    【解决方案1】:

    要运行已编译的脚本(文件),您必须省略 -e 标志并将完整路径传递给脚本

    /usr/bin/osascript /Users/myUser/path/to/my_script.scpt
    

    【讨论】:

      【解决方案2】:

      如果你写

      osascript -e "set Volume 10"
      

      -e之后是脚本的全部内容。

      如果你放入某个文件(我们称之为volume.scpt

      set Volume 10
      

      您可以将脚本文件称为

      osascript /path/to/volume.scpt
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多