Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maybe this one will interest you? <code>proc_open()</code> - <a href="http://www.php.net/manual/en/function.proc-open.php" rel="nofollow">http://www.php.net/manual/en/function.proc-open.php</a></p> <p>And here is a handy snippet which might work for you (it's copied from the comments on the site I gave you the link to):</p> <pre><code>&lt;?php /* * Execute and display the output in real time (stdout + stderr). * * Please note this snippet is prepended with an appropriate shebang for the * CLI. You can re-use only the function. * * Usage example: * chmod u+x proc_open.php * ./proc_open.php "ping -c 5 google.fr"; echo RetVal=$? */ define(BUF_SIZ, 1024); # max buffer size define(FD_WRITE, 0); # stdin define(FD_READ, 1); # stdout define(FD_ERR, 2); # stderr /* * Wrapper for proc_*() functions. * The first parameter $cmd is the command line to execute. * Return the exit code of the process. */ function proc_exec($cmd) { $descriptorspec = array( 0 =&gt; array("pipe", "r"), 1 =&gt; array("pipe", "w"), 2 =&gt; array("pipe", "w") ); $ptr = proc_open($cmd, $descriptorspec, $pipes, NULL, $_ENV); if (!is_resource($ptr)) return false; while (($buffer = fgets($pipes[FD_READ], BUF_SIZ)) != NULL || ($errbuf = fgets($pipes[FD_ERR], BUF_SIZ)) != NULL) { if (!isset($flag)) { $pstatus = proc_get_status($ptr); $first_exitcode = $pstatus["exitcode"]; $flag = true; } if (strlen($buffer)) echo $buffer; if (strlen($errbuf)) echo "ERR: " . $errbuf; } foreach ($pipes as $pipe) fclose($pipe); /* Get the expected *exit* code to return the value */ $pstatus = proc_get_status($ptr); if (!strlen($pstatus["exitcode"]) || $pstatus["running"]) { /* we can trust the retval of proc_close() */ if ($pstatus["running"]) proc_terminate($ptr); $ret = proc_close($ptr); } else { if ((($first_exitcode + 256) % 256) == 255 &amp;&amp; (($pstatus["exitcode"] + 256) % 256) != 255) $ret = $pstatus["exitcode"]; elseif (!strlen($first_exitcode)) $ret = $pstatus["exitcode"]; elseif ((($first_exitcode + 256) % 256) != 255) $ret = $first_exitcode; else $ret = 0; /* we "deduce" an EXIT_SUCCESS ;) */ proc_close($ptr); } return ($ret + 256) % 256; } /* __init__ */ if (isset($argv) &amp;&amp; count($argv) &gt; 1 &amp;&amp; !empty($argv[1])) { if (($ret = proc_exec($argv[1])) === false) die("Error: not enough FD or out of memory.\n"); elseif ($ret == 127) die("Command not found (returned by sh).\n"); else exit($ret); } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload