5

CentOSでCutyCaptを使用しています。ターミナル経由では正常に動作しますが、phpexec関数経由では動作しません。ターミナルのコマンドでxvfbを起動しました:

Xvfb :99 -screen 0 1024x768x24

そして、私はphpスクリプトでスクリーンショットを撮ろうとしています:

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

エラーは表示されませんが、出力ファイルがありません(出力ディレクトリにはchmod 777があります)誰かが私を助けてくれますか?

ありがとう

UPD: ApacheによるXvfbの実行を許可する方がどういうわけか良いのでしょうか?

4

1 に答える 1

3

最後にphpを使用してCutyCaptを正常に実行することができました。$ _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;
 }
于 2013-03-15T18:03:36.860 に答える