简体   繁体   English

命令通过终端正常工作,但不能通过shell_exec php运行

[英]command works fine through terminal but not shell_exec php

Got a weird issue i have installed wav2png on my mac osx with lion now and works fine when using terminal no problem but when i try to run it using shell_exec with php like below 出现一个奇怪的问题,我现在已经在狮子的mac osx上安装了wav2png,并且在使用终端时可以正常工作,但是当我尝试使用shell_exec和php来运行它时,如下所示

$wav2png = shell_exec("cd {$targetDir} && /usr/bin/wav2png --foreground-color=000000ff --background-color=00000000 -o example2.png f86150f88d.wav 2>&1");
echo "<pre>" . $wav2png . "</pre>";

I get the output 我得到了输出

dyld: Library not loaded: /opt/local/lib/libpng15.15.dylib
  Referenced from: /usr/bin/wav2png
  Reason: Incompatible library version: wav2png requires version 28.0.0 or later, but libpng15.15.dylib provides version 23.0.0

Cant find a way to update libpng??? 无法找到更新libpng的方法???

Any suggestions why it will work fine through terminal but not shell_exec php? 有什么建议为什么它可以通过终端正常运行,但不能通过shell_exec php正常运行?

I think problem is in LD_LIBRARY_PATH and/or with library paths in general. 我认为问题出在LD_LIBRARY_PATH和/或库路径中。

Go to shell and type 转到外壳并输入

echo $LD_LIBRARY_PATH

and

ldd /usr/bin/wav2png

Do exact same from php script (be sure to grab output from these commands) and compare, I'm pretty sure you find the answer. 从php脚本执行完全相同的操作(请确保从这些命令中获取输出)并进行比较,我很确定您找到了答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当执行命令lftp时php exec或shell_exec无效 - Php exec or shell_exec not works when execute command lftp 带有命令的 PHP shell_exec 的行为方式与通过终端执行时不同 - PHP shell_exec with a command does not behave the same way as when it is executed through the terminal 使用zenity的bash脚本在终端中工作但不在php shell_exec中工作 - bash script using zenity works in terminal but not in php shell_exec php shell_exec在浏览器中不起作用,但在终端中起作用 - php shell_exec doesn't work in browser but works in terminal PHP和FFmpeg:在终端上工作,但在shell_exec中时出现ffmpeg错误 - PHP and FFmpeg : works on terminal but ffmpeg error when in shell_exec 无法通过PHP中的shell_exec()函数运行wkhtmltopdf逗号,但在命令行上可以使用相同的命令 - Not able to run wkhtmltopdf commad through shell_exec() function in php but same command works on command line php shell_Exec在外壳程序中运行时无法正常工作 - php shell_Exec not working while the command works in shell curl命令行有效,php shell_exec()不起作用 - curl command line works, php shell_exec() does not 带有shell_exec的命令行PHP适用于root用户,但不适用于其他用户 - Command Line PHP with shell_exec works for root but not others AWS CLI命令可在Bash上运行,但不适用于PHP shell_exec() - AWS CLI command works on Bash, but not with PHP shell_exec()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM