PHP exec 输出不 return 并执行命令

PHP exec output does not return and execute commands

我正在尝试在 Windows 服务器计算机上执行 PHP 中的命令。

我使用的代码是:

<?php
$out = array();
exec('C:\libs\bin\youtube-dl -o "C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw"  "http://youtube.com/watch?v=SrMKY5Aoyrw"', $out);
print_r($out);
?>

我在 PHP 中的结果是:

Array
(
[0] => [youtube] SrMKY5Aoyrw: Downloading webpage
[1] => [youtube] SrMKY5Aoyrw: Downloading video info webpage
[2] => [youtube] SrMKY5Aoyrw: Extracting video information
[3] => [youtube] SrMKY5Aoyrw: Downloading DASH manifest
[4] => [youtube] SrMKY5Aoyrw: Downloading DASH manifest
)

我的结果应该是:

C:\xampp\htdocs\API\jbb15\convert>C:\libs\bin\youtube-dl -o "C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw" "http://youtube.com/watch?v=SrMKY5Aoyrw"
[youtube] SrMKY5Aoyrw: Downloading webpage
[youtube] SrMKY5Aoyrw: Downloading video info webpage
[youtube] SrMKY5Aoyrw: Extracting video information
[youtube] SrMKY5Aoyrw: Downloading DASH manifest
[youtube] SrMKY5Aoyrw: Downloading DASH manifest
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw.f137
[download] 100% of 111.72MiB in 00:01
[download] Destination: C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw.f251
[download] 100% of 8.13MiB in 00:00
[ffmpeg] Merging formats into "C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw.mkv"
Deleting original file C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw.f137 (pass -k to keep)
Deleting original file C:\xampp\htdocs\API\jbb15\convert\SrMKY5Aoyrw.f251 (pass -k to keep)

关于此的问题是:如果将命令复制到 Windows CMD 中,与上述 PHP 脚本中完全相同的命令将完美运行。没有 PHP 错误日志。命令 --verbose return 在 PHP 中没有任何作用,但在 windows cmd.

中有效

感谢您的贡献。问题是我没有设置 > msg.log 2> msg2.log.

WARNING: Requested formats are incompatible for merge and will be merged into mkv. 行在 2> 中是 运行,因此停止了执行。

命令--no-warnings可能也解决了。