I wrote a small application in Java and a script in php. I'm basically try to auto fill in a prompt using php while running the proc_open() function.
Here is my Java:
public class InputTester {
public static void main(String[] args){
System.out.println("Output line");
String said = System.console().readLine("Say Something:");
System.out.println("You said: " + said);
}
}
And here is the PHP I'm trying to use to run it:
<?php
$error_output_file = "/tmp/error-output.txt";
$command = "java -jar InputTester.jar";
$descriptorspec = array(
0 => array("pipe", "r"), //stdin
1 => array("pipe", "w"), //stdout
2 => array("file", $error_output_file, "a") //stderr
);
$proc = proc_open($command, $descriptorspec, $pipes);
if (is_resource($proc)) while ($s = fgets($pipes[1])) {
echo $s;
if(strpos($s, "Something:")) fwrite($pipes[0], 'the thing');
}
?>
But, when I run php input_tester.php
All I get is: Output line
and then it closes. Does anyone know why?..