Consider this code running on apache 1.3.27 with php 4.3.2 on Windows 2000
$failed = false; // authentication failure flag
$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("CMD.EXE", $descriptorspec, $pipes);
echo $process;
if (is_resource($process)) {
while(!feof($pipes[1])) {
$line = fgets($pipes[1], 1024);
$loginFailed = strpos($line, "invalid login name or password");
/** DEBUG OUTPUT */
echo $line;
echo "<br>";
}
fclose($pipes[1]);
$return_value = proc_close($process);
echo "<br><b>command returned<b> $return_value\n";
}
It just freezes on me!
Eventually what i want to do is open up a telnet process to telnet out to another box and run some commands
and grab the output for me. However CMD.exe just hangs and if i try proc_open with telnet binary it will not return anything.
for example
fwrite($pipes[0],"ls -ls");
$line=fgets($pipes[1], 1024) - line will not return anything.
I ran some of the code on unix platform and it worked so probably some settings issue
Anyone have any idea?