Trying to read off the process input stream
<p>In the following scenario we're dealing with a console application where there is a PHP script running as a process from within a java application.  Each time the script is fed with two values and returns either "OK" or "ERR".  I'm trying to capture the time it takes from when the inputs are fed into the script and the time it return with either an "OK" or "ERR" value.</p>

<p>I have implemented the following fix, but it still doesn't seem to work.  If anyone could shed some light.</p>

<pre><code>try {
        proc = runtime.exec("php " + "script.php");            


        inp = new BufferedReader( new InputStreamReader(proc.getInputStream()) );
        out = new BufferedWriter( new OutputStreamWriter(proc.getOutputStream()) );

        while (true) {
            temp = getRandomUser() + " " + getRandomHost();
            startTime = System.currentTimeMillis();
            //System.out.println(temp);

            print(pipe(temp));

            while (!inp.readLine().equals("ERR") || !inp.readLine().equals("OK")) {
            }

            endTime = System.currentTimeMillis();
            procTime = (long) endTime - startTime;

            fout.write(Double.toString(procTime));
            fout.newLine();
            //System.out.println("! " + procTime);
        }


} catch (IOException ex) {
        System.out.println("Thread prematurely Terminated...");
} 
</code></pre>
