Running applescript from Matlab

6 次查看(过去 30 天)
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!

采纳的回答

Walter Roberson
Walter Roberson 2014-1-28
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" ');
  1 个评论
Nicolas
Nicolas 2014-1-29
Thank you very much Walter. Works perfectly. I really appreciate your help!

请先登录,再进行评论。

更多回答(1 个)

Plem Sah
Plem Sah 2016-4-6
Very helpful thank you! I experienced the same problem.

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by