本文共 955 字,大约阅读时间需要 3 分钟。
I just cant figure it out how can execute shell commands on php. it must suppose to echo the parameters of mogrify but it always return false. How could i do it on a macbook pro yosemite? i already tried editing all users permissions to read/write/execute but still no luck.. already tried researching the web about this and cant get the answer.
my code is:
echo shell_exec("/opt/ImageMagick/bin/mogrify");
?>
解决方案
OK for all of you to solve this kind of problem that any terminal application don't run on mac and returns null in any kind of calling terminal apps like shell_exec, exec, system etc. this is the one of a kind that took me 24 hours to know.. it's about the working dir.
// The Code that took me 24 Hours to Discover.
exec('unset DYLD_LIBRARY_PATH ;');
putenv('DYLD_LIBRARY_PATH');
putenv('DYLD_LIBRARY_PATH=/usr/bin');
$voila = shell_exec("anything you want to execute!");
var_dump($voila);
with that work around your problem will be fixed.
转载地址:http://poqms.baihongyu.com/