0

我正在使用带有 proc_open 的 php 脚本来立即在浏览器上获取 shell 输出。这项工作在 cli 但不是通过网络这是我的脚本:

//$arr_pipes = array( );

$str_command = './something.sh';


$descriptorspec = array(

    0 => array("pipe", "r"),  // stdin
    1 => array("pipe", "w"),  // stdout -> we use this
    2 => array("pipe", "w")   // stderr 

);

//   0 => array( "file", "php://stdin", "r" ),   // stdin is a file that the child will read from
//   1 => array( "file", "php://stdout", "w" ),  // stdout is a file that the child will write to
//   2 => array( "file", "/dev/null", "w" )      // stderr is a file that the child will write to



$process = @proc_open( $str_command, $descriptorspec, $pipes );
//$process = proc_open( $str_command, $descriptorspec, $arr_pipes);



if ( is_resource( $process ) )

{

 while( ! feof($pipes[1]))

    {
        $return_message = fgets($pipes[1], 1024);
        if (strlen($return_message) == 0) break;
        echo "<pre>$return_message</pre>";
    }

}


?>
4

0 回答 0