首页 > 解决方案 > 从 PHP 脚本启动 uboost.py 时出错

问题描述

从 PHP 脚本启动 uboost.py 时出现此错误

无法使用 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37 python.exe "C:\uboost\uboost.py" arg1 arg2 创建进程;回声退出状态:$?

我从这个脚本运行它:

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

希望有人知道原因 谢谢

标签: phppython

解决方案


推荐阅读