I've created two programs in C. The first gets a number and prints the double value of it and the second prints the quadruple.
I want to execute them
through PHP. I've done it using proc_open and it works fine if I execute only one of the programs each time.
I have to give a number to the
first program and pass its output as input to the second program. When though I use two proc_open to create the two processes,the whole thing doesn't work.
What I want to do is something like this:
$process1 = proc_open($command_exe1, $descriptorspec1, $pipes1, $cwd);
$process2 = proc_open($command_exe2, $descriptorspec2, $pipes2, $cwd);
fwrite($pipes1[0], $posted);
fwrite($pipes2[0], $pipes1[1]);
fclose($pipes1[0]);
fclose($pipes2[0]);
while(!feof($pipes1[1])) {
$StdOut1 = stream_get_contents($pipes1[1]);
}
echo $StdOut1;
while(!feof($pipes2[1])) {
$StdOut2 = stream_get_contents($pipes2[1]);
}
echo $StdOut2;
fclose($pipes1[1]);
fclose($pipes2[1]);
proc_close($process1);
proc_close($process2);
I know that it's a wrong way of doing it but I can't think of anything else so...any help would be welcome. Note: I'm working on Windows.