如何在Mac中使用shell_exec xampp php [英] How to use shell_exec xampp php in a Mac

查看:182
本文介绍了如何在Mac中使用shell_exec xampp php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想不通如何在php上执行shell命令.它必须假设回显mogrify的参数,但始终返回false.我怎么能在Macbook Pro优胜美地上做到这一点?我已经尝试编辑所有用户的权限以进行读/写/执行,但是仍然没有运气..已经尝试在网络上对此进行研究并无法得到答案.

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.

我的代码是:

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

推荐答案

OK,解决所有终端应用程序都不在mac上运行并且在诸如shell_exec之类的任何调用终端应用程序中返回null的问题,执行程序,系统等.这是我花了24小时才知道的一种...这是关于工作目录的.

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.

这篇关于如何在Mac中使用shell_exec xampp php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆