从 php 运行蹩脚

发布于 2024-09-02 01:32:53 字数 387 浏览 15 评论 0原文

我正在尝试从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

请止步禁区 2024-09-09 01:32:53

尝试这样的事情:

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

$output 应该是输出中包含的行数组

$result 应该是整数结果代码。 0 通常表示成功,>=1 表示错误(具体代码取决于应用程序)。

2>&1 部分会将 STDERR 重定向到 STDOUT ($output),这通常会被删除。因此,如果出现错误,您应该能够看到错误(希望如此)。

如果 $result 转储得到 -1,则存在根本问题,因为这不是有效的结果代码(这可能意味着 exec 被禁用,或者您尝试运行的进程由于权限错误或这样的)...

Try something like this:

$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

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

肥爪爪 2024-09-09 01:32:53

如果您觉得需要更方便的方式来使用 lame,我建议使用 phplame 包装器。使用 Composer 安装 PHP LAME 包装器:

{
    "require": {
        "b-b3rn4rd/phplame": "dev-master"
    }
}

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:

{
    "require": {
        "b-b3rn4rd/phplame": "dev-master"
    }
}
非要怀念 2024-09-09 01:32:53

设置错误报告并检查是否可以执行 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.

饭团 2024-09-09 01:32:53

可能是 $PATH 问题。尝试指定 lame 的完整路径,即。 /usr/local/bin/lame

Might be a $PATH problem. Try specifying the full path to lame, ie. /usr/local/bin/lame.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文