2017-04-01 121 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