问题
I have apple script which is working perfectly fine, until I add use script “Alert Utilities”
at the start. Then it gives Expected end of line, etc. but found identifier. error at set md5 to do shell script "md5 -q " & quoted form of myFile
with shell
highlighted. What could possible be causing this error?
回答1:
Add use scripting additions
and the code will run fine. Since AppleScript 2.3 (Mavericks) there is the new use
statement. It will tell the neccessary resources that are required to run the script like which applications (optional), script libraries, cocoa frameworks in AppleScriptObjC or if it will use scripting additions or not. For backward compatibility when the use
statement is not used, by default scripting addition are loaded. If the use
statement is used, the scripting additions are by default not loaded.
So your script will look like:
use script “Alert Utilities”
use scripting additions
-- continue code
set md5 to do shell script "md5 -q " & quoted form of myFile
回答2:
Add use "scripting additions"
statement. use
statement automatically disables scripting addtions such as display dialog
.
also,
set md5 to (do shell script "md5 -q " & quoted form of myFile with shell)
来源:https://stackoverflow.com/questions/29666090/end-of-line-error-due-to-use-script