1
osascript -e "set x to 3"
osascript -e "if x is 5 then"
osascript -e "    tell application \"System Events\" to keystroke return"
osascript -e "end if"

私が得る出力

14:14: syntax error: Expected end of line but found end of script. (-2741)
0:6: syntax error: A “if” can’t go after this “end”. (-2740)

スクリプトの何が問題なのかわかりません。インデントに問題がある可能性があります。bash ファイル内で osascript を使用した人はいますか?

4

2 に答える 2

0

Put all your applescript lines together. This way:

osascript -e "set x to 3
if x is 5 then
tell application \"System Events\" to keystroke return
end if"

Additionally, you can create a file like the following with all your applescript code:

#!/usr/bin/osascript
set x to 3
if x is 5 then
    tell application "System Events" to keystroke return
end if
于 2015-04-29T07:59:28.120 に答える