从 php 运行蹩脚
我正在尝试从 php 脚本运行蹩脚。
我已经尝试过这些,但没有运气,我没有得到任何回报!有什么想法吗?
system('lame', $returnarr);
system('lame --help', $returnarr);
exec('lame', $returnarr);
passthru('lame', $returnarr);
即使这个也没有返回任何内容:
exec('which lame', $returnarr);
我在 OSX 上,最终部署将在 Linux 上。对于自动 wav->mp3 转换,您有更好的建议吗? 我应该从 php 执行一个执行 Lame 的 bash 脚本吗?
I am trying to run lame from a php script.
I have tried these, but no luck, I don't get anything returned! Any ideas?
system('lame', $returnarr);
system('lame --help', $returnarr);
exec('lame', $returnarr);
passthru('lame', $returnarr);
even this one returns nothing:
exec('which lame', $returnarr);
I am on OSX and final deployment will be on Linux. Do you have better suggestions for an automated wav->mp3 conversion?
From php, should I execute a bash script that executes Lame?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试这样的事情:
$output 应该是输出中包含的行数组
$result 应该是整数结果代码。 0 通常表示成功,>=1 表示错误(具体代码取决于应用程序)。
2>&1 部分会将 STDERR 重定向到 STDOUT ($output),这通常会被删除。因此,如果出现错误,您应该能够看到错误(希望如此)。
如果 $result 转储得到 -1,则存在根本问题,因为这不是有效的结果代码(这可能意味着 exec 被禁用,或者您尝试运行的进程由于权限错误或这样的)...
Try something like this:
$output should be an array of lines contained in the output
$result should be an integer result code. 0 is typically success, >=1 is an error (specific codes are application dependant).
The 2>&1 part will redirect STDERR to STDOUT ($output) which would normally be dropped. So if it's erroring out, you should be able to see the error (hopefully).
If you get -1 for the dump of $result, there's a fundimental problem, because that's not a valid result code (it likely means that exec is disabled, or the process you're trying to run is restricted because of permissions errors or the such)...
如果您觉得需要更方便的方式来使用
lame
,我建议使用 phplame 包装器。使用 Composer 安装 PHP LAME 包装器:If you feel a need for more convenient way to work with
lame
, I would recommend to use phplame wrapper. Install PHP LAME wrapper using Composer:设置错误报告并检查是否可以执行 exec。默认情况下,大多数系统不允许这样做,这是一个严重的安全责任。您必须在 php.ini 中明确允许执行。
set error reporting on and check if you can do exec's. By default most systems wont allow it, it's a serious security liability. You've got to explicitly allow execs in php.ini.
可能是
$PATH
问题。尝试指定 lame 的完整路径,即。/usr/local/bin/lame
。Might be a
$PATH
problem. Try specifying the full path to lame, ie./usr/local/bin/lame
.