PHP exec - 缺少输出
我目前正在尝试让 SoX 通过 PHP 工作。到目前为止一切正常,但我没有得到输出。我已经读到,人们也可能将 stderr 路由到带有“2>&1”的输出。问题是,这似乎在 Windows 机器上不起作用。
还有其他想法吗?
代码如下:
exec($path2sox . '/sox ' . $cmd . ' 2>&1', $output = array(), $result);
虽然文件被创建(所以基本的 sox 命令是可以的,我也在 Windows 命令行中测试了完全相同的命令),但结果和输出都没有给出任何回报(SoX 详细程度设置为 4,这是完整输出)
我想,Windows 不理解 2>&1 语句,但是如何克服这个问题?
PS:正如下面所建议的,我也尝试过这个,
$output = array();
echo "Executing: [$path2sox/sox $cmd]";
exec("$path2sox/sox $cmd", $output, $result);
echo "Result: ";
var_dump($result);
echo "\n
Output: ";
var_dump($output);
输出是:
Executing: [I:\SoX/sox --guard -V4 "somedirectory/test.wav" --compression "320.2" "somedirectory/test.mp3"]Result: int(0)File was created properly ...
输出:数组(0){ }
I am currently trying to get SoX working through PHP. It all works so far, but I don't get the output back. I've already read that one might route stderr also to the output with "2>&1" .. the problem is, this doesn't seem to work on windows machines.
any other ideas?
code is as follows:
exec($path2sox . '/sox ' . $cmd . ' 2>&1', $output = array(), $result);
whereas the file gets created (so basic sox command is okay, i also tested it exactly the same command in the windows commandline), but neither result nor output give something in return (SoX verbosity is set to 4, which is full output)
I suppose, windows doesnt understand the 2>&1 statement, but how can this be overcome?
P.S: as suggested below, I also tried this
$output = array();
echo "Executing: [$path2sox/sox $cmd]";
exec("$path2sox/sox $cmd", $output, $result);
echo "Result: ";
var_dump($result);
echo "\n
Output: ";
var_dump($output);
where the output is:
Executing: [I:\SoX/sox --guard -V4 "somedirectory/test.wav" --compression "320.2" "somedirectory/test.mp3"]Result: int(0)
Output: array(0) { }
File was created properly ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否传递第二个输出数组参数?
https://www.php.net/manual/en/function.exec。 php
Are you passing the second output array parameter?
https://www.php.net/manual/en/function.exec.php
我怀疑您可能是对的,Windows 不喜欢
2>&1
语句。当你尝试时你会看到什么:I suspect you might be right that windows isn't liking the
2>&1
statement. What do you see when you try: