所以我试图从命令行一次性运行多个 Applescript 命令。然而,无论我如何尝试,它都行不通:
$ osascript -e "set x to 0; display dialog x"
$ osascript -e "set x to 0 \n display dialog x"
$ osascript -e "set x to 0 then display dialog x"
有没有办法在不保存到文件的情况下执行此操作?
最佳答案
这对我有用:
osascript -e "set x to 0" -e "display dialog x"
查看终端中osascript
手册页中的-e
选项 :man osascript
−e statement
Enter one line of a script. If −e is given, osascript will not look for a filename in the argument list. Multiple −e options may be given to build up a multi-line script. Because most scripts use char- acters that are special to many shell programs (for example, AppleScript uses single and double quote marks, “(”, “)”, and “∗”), the statement will have to be correctly quoted and escaped to get it past the shell intact.
您还可以这样做:
osascript <<END
set x to 0
display dialog x
END
或者:
osascript -e '
set x to 0
display dialog x'
关于applescript - 来自终端 osascript 调用的多个 Applescript 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69246651/