How to use shell_exec xampp php in a Mac

只谈情不闲聊 提交于 2020-01-23 19:39:24

问题


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:

<?php
echo shell_exec("/opt/ImageMagick/bin/mogrify");
?>

回答1:


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.



来源:https://stackoverflow.com/questions/30549181/how-to-use-shell-exec-xampp-php-in-a-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!