PHP Exec没有运行,但命令工作正常!

Lia*_*amB 0 php

我有以下脚本在PHP中获取上传的PDF并调用ImageMagik/Ghostscript转换为指定大小的图像.

$tmp = exec("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"", $results); 
Run Code Online (Sandbox Code Playgroud)

但是,这似乎不起作用.日志文件中没有错误,屏幕上没有错误.如果我这样做,

$tmp = exec("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"", $results); 
echo ("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"");
Run Code Online (Sandbox Code Playgroud)

然后我将输出粘贴到命令提示符下它工作正常(大约需要6-10秒 - 我的max_execution_time是600.

为什么这可能不起作用的任何建议?

这是Windows,IIS 7和PHP5.

编辑:我在CentOS和Windows中都遇到了同样的问题.两者都安装了ImageMagik和Ghostscript.

编辑编辑以下仍然失败.

$handle = popen("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"","r");
        echo "'$handle'; " . gettype($handle) . "\n";
        $read = fread($handle, 2096);
        echo $read;
        pclose($handle);
Run Code Online (Sandbox Code Playgroud)

小智 5

尝试在命令末尾添加2>&1.我在这里找到.

exec('some_command 2>&1', $output);
print_r($output);  // to see the respond to your command
Run Code Online (Sandbox Code Playgroud)