Je rencontre actuellement un problem avec PHP (CLI)
J'exécute la commande suivante dpkg-reconfigure mysql-server-5.1 comme suite:
$timeout = 15;
$descriptorspec = array(
0 => array("pipe", 'r'), // stdin is a pipe that the child will read from
1 => array("pipe", 'w'), // stdout is a pipe that the child will write to
2 => array("pipe", 'w') // stderr is a pipe that the child will write to
);
$process = proc_open('dpkg-reconfigure mysql-server-5.1', $descriptorspec, $pipes);
$streams = array(
'PSTDIN' => $pipes[0],
'PSTDOUT' => $pipes[1],
'PSTDERR' => $pipes[2],
'STDIN' => STDIN
);
if (is_resource($process)) {
while (!feof($pipes[1])) {
$read = $streams;
$n = stream_select($read, $write = null, $e = null, $timeout);
if ($n > 0) {
foreach ($read as $r) {
$key = array_search($r, $streams);
if ($key == 'STDIN') {
fwrite($streams['PSTDIN'], fflush($streams[$key]));
} elseif ($key == 'PSTDOUT' || $key == 'PSTDERR') {
echo fread($streams[$key], 1);
}
}
}
}
} else {
fwrite(STDOUT, "System was unable to execute external command" . PHP_EOL);
}
J'obtiens l'écran suivant:
Comme vous pouvez le constater dans l'image jointe, la fenêtre de dialogue n'occupe pas tout l'espace disponible.
Or, si j'éxecute exactement la même commande via la function passthru()
passthru('dpkg-reconfigure mysql-server-5.1 2>&1', $retVal);
J'obtiens l'écran suivant:
Ma question est simple:
Comment obtenir le résultat de la deuxième image en exécutant la commande via proc_open ?
J'aimerais bien savoir ce qui provoque une telle différence.
Vous remerciant par avance.