2017-04-01 68 views
0

运行,为什么不从终端我AppleScript的运行,我可以成功地从编辑的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 

回答

3

要运行已编译脚本(文件),你必须省略-e旗帜,并通过完整路径脚本

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

谢谢你现在的作品。 – wpj

0

如果你写

osascript -e "set Volume 10" 

-e之后是脚本的完整内容。

如果你把某些文件(可以称之为volume.scpt

set Volume 10 

可以调用脚本文件作为

osascript /path/to/volume.scpt