运行从PHP瘸 [英] Running lame from php

查看:179
本文介绍了运行从PHP瘸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行PHP脚本跛。

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);

我在OSX和最后的部署将在Linux上。你有一个自动WAV的> MP3转换更好的建议?
从PHP,我应该执行该执行瘸一bash脚本?

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?

推荐答案

尝试是这样的:

$output = array();
$result = -1;
exec('`/usr/bin/which lame` --help 2>&1', $output, $result);
var_dump($output, $result);

$输出应该包含在输出线的阵列

$output should be an array of lines contained in the output

$结果应该是一个整数code。 0通常是成功,> = 1是一个错误(具体codeS取决于应用程序)。

$result should be an integer result code. 0 is typically success, >=1 is an error (specific codes are application dependant).

在2>&安培; 1部分将STDERR重定向到这通常被丢弃STDOUT($输出)。所以,如果它的示数了,你应该可以看到错误(希望)。

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).

如果你得到-1 $结果的转储,有一个fundimental问题,因为这不是一个有效的结果code(这可能意味着EXEC被禁用,或者你想运行过程中受到限制因为权限错误或此类)的...

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)...

这篇关于运行从PHP瘸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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