duanqinjiao5244 2015-10-04 15:20
浏览 731
已采纳

PHP exec输出不返回并执行命令

I am trying to execute a command in PHP on a Windows Server Machine.

The code i am using is:

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

My result in PHP is:

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
)

My result should be:

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)

The problem about this is: The exact same command as in the above PHP script works perfectly if the command is copied into the Windows CMD. There are no PHP error logs. The command --verbose will return nothing in PHP, but works in windows cmd.

  • 写回答

1条回答 默认 最新

  • douyun8901 2015-10-04 16:05
    关注

    Thanks for contributing. The problem was that i did not set > msg.log 2> msg2.log.

    The line WARNING: Requested formats are incompatible for merge and will be merged into mkv. was run in 2> and therefore stopped the execution.

    The command --no-warnings might have solved it too.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)