title: Writing to stdin from PHP?
body: <p>In linux I want to run a gnome zenity progress bar window from PHP.  How zenity works is like this:</p>
  
  <pre><code>linux-shell$ zenity --display 0:1 --progress --text='Backing up' --percentage=0
  10
  50
  100
  </code></pre>
  
  <p>So the first command opens the zenity progress bar at 0 percent.  Zenity then takes standard input numbers as the progress bar percentage (so it will go from 10% to 50% to 100% when you type those numbers in).</p>
  
  <p>I can't figure out how to get PHP to type in those numbers though, I have tried:</p>
  
  <pre><code>exec($cmd);
  echo 10;
  echo 50;
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>$handle = popen( $cmd, 'w' );
  fwrite( $handle, 10 );
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>$descriptorspec = array(
     0 =&gt; array("pipe", "r"),  // stdin is a pipe that the child will read from
     1 =&gt; array("pipe", "w")  // stdout is a pipe that the child will write to
  );
  
  $h = proc_open($cmd, $descriptorspec, $pipes);
  
  fwrite($pipes[1], 10);
  </code></pre>
  
  <p>But none of them updates the progress bar.  In what way can I mimic the effect of the stdin on the linux shell to get zenity to update its progress bar?</p>