从PHP scrip启动uboost.py时出错

2024-06-28 15:29:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我在从PHP脚本启动uboost.py时遇到这个错误

Unable to create process using 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37 python.exe "C:\uboost\uboost.py" arg1 arg2 ; echo Exit status : $?'

我使用以下脚本运行它:

<?php
function liveExecuteCommand($cmd)
{

    while (@ ob_end_flush()); // end all output buffers if any

    $proc = popen("$cmd 2>&1 ; echo Exit status : $?", 'r');

    $live_output     = "";
    $complete_output = "";

    while (!feof($proc))
    {
        $live_output     = fread($proc, 4096);
        $complete_output = $complete_output . $live_output;
        echo "$live_output";
        @ flush();
    }

    pclose($proc);

    // get exit status
    preg_match('/[0-9]+$/', $complete_output, $matches);

    // return exit status and intended output
    return array (
                    'exit_status'  => intval($matches[0]),
                    'output'       => str_replace("Exit status : " . $matches[0], '', $complete_output)
                 );
}
    //$output = shell_exec('python C:/uboost/uboost.py pignalice Cazzo1234');
    liveExecuteCommand("python C:/uboost/uboost.py pignalice Cazzo1234");
?>

希望有人知道原因 谢谢


Tags: pyecho脚本cmdliveoutputstatusexit