【问题标题】:CutyCapt with php execCutyCapt 与 php 执行
【发布时间】:2013-02-27 15:36:11
【问题描述】:

我在我的 CentOS 上使用 CutyCapt。 它可以通过终端正常工作,但不能通过 php exec 函数工作。 我已经在终端中通过命令启动了 xvfb:

Xvfb :99 -screen 0 1024x768x24

我正在尝试通过 php 脚本进行截图:

exec("DISPLAY=:99 /path/to/cutycapt --url=<some url> --out=<path/to/output>");

它没有显示任何错误但没有输出文件(输出目录有 chmod 777) 有人可以帮帮我吗?

谢谢

统一更新: 也许允许 Apache 执行 Xvfb 会更好?

【问题讨论】:

  • 尝试以下代码并发布结果。 $output = array(); $return_var = null; $result = exec("DISPLAY=:99 /path/to/cutycapt --url=&lt;some url&gt; --out=&lt;path/to/output&gt;", $output, $return_var); var_dump($result); var_dump($output); var_dump($return_var);

标签: php cutycapt


【解决方案1】:

我已经设法让 CutyCapt 最后使用 php 成功运行。 $_parameters 通过 AJAX 传递给 php 脚本。希望这会有所帮助...

 case 'Output_Chart': {

    // We always create the .png.  We use the  ImageMagick convert (IMC) command to make .pdfs
    if ($_Suffix == 'pdf') {
       $IMC = ";convert -page 735x850 '$_PathOut/$_ChartName.png' '$_PathOut/$_ChartName.pdf'";
    } else {
       $IMC = '';
    }

    // Prepare the query string for the CutyCapt URL
    $sQuery_Pattern   = '?Path=%s&iDL=%d';
    $sQuery           = sprintf($sQuery_Pattern, $_Path, $_iDL);

    // Prepare CutyCapt's command and parameters (NB: query string and out parameter are enclosed in aposts for the shell)
    $sCC_Cmd          = '/var/www/LF/Includes/CutyCapt';
    $sCC_URL          = "http://localhost/LF/LFPrint.html'$sQuery'";     // Note: Inner apostrophes
    $sCC_Out          = "'$_PathOut/$_ChartName.png'";
    $sCC_Pattern      = ' --url=%s --out=%s --delay=%d --min-width=%d';
    $sCC_Options      = sprintf($sCC_Pattern, $sCC_URL, $sCC_Out, $_Delay, $_MinWidth);
    //$sCC_CmdLine         = $sCC_Cmd . $sCC_Options . " 2> CutyCapt.err.txt";
    $sCC_CmdLine         = $sCC_Cmd . $sCC_Options . " 2> /dev/null";

    // Prepare the final command line with xvfb-run, CutyCapt, and the URL?QueryString
    $sCC_CmdLine = 'xvfb-run --auto-servernum --server-args="-screen 0, 800x1000x24" ' . $sCC_CmdLine . $IMC;
    exec( $sCC_CmdLine, $aOutput = array(), $ret);
    // Wait for and then return the results.  sCC_CmdLine and aOutput are just for debugging
    echo json_encode(array("ret" => $ret, "cmd" => $sCC_CmdLine, "Output" => $aOutput));
    break;
 }

【讨论】:

    猜你喜欢
    • 2014-04-24
    • 1970-01-01
    • 1970-01-01
    • 2012-09-08
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多