MATLAB: Running applescript from Matlab

applescriptdyldMATLABosascriptscptsystem

Hi all,
I have an AppleScript that takes a filepath as an input, and returns a string. In terminal, it works just fine when I run:
osascript getComment.scpt ":file:path:to:rabbit.png"
I get the expected returned value:
rabbitComment
I am now trying to run it from a Matlab function, using the system command.
[status, result] = system('osascript getComment.scpt "file:path:to:rabbit.png" ');
I get
result = dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/osascript) is code signed with entitlements
rabbitComment
Status is 0, meaning no error occurred. Does anyone have any idea why this DYLD warning is raised, and how to avoid this?
Thank you very much!

Best Answer

MATLAB extends the DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH environment variables that it passes into the shell, in order to add on the path to MATLAB libraries (and to Java libraries).
osascript is a program which has extended privileges ("entitlements") assigned to it.
When a program has extended privileges assigned to it, the operating system needs to ignore any shell variables about the dynamic library paths, so that a malicious user does not substitute their own library for one of the expected system libraries, thereby getting their own code executed in a privileged context.
When a program with extended privileges is executed, it gives a warning that it ignored the dynamic library variables.
The easiest workaround would be
[status, result] = system('unset DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH; osascript getComment.scpt "file:path:to:rabbit.png" ');