title: Live output to a file with PHP exec()?
body: <p>On Windows, I use PHP to execute a <code>gulp</code> command.</p>
  
  <p>Like this :</p>
  
  <pre><code>&lt;?php
  
       set_time_limit(0);
  
       exec("cd /projectpath");
       $results = exec("gulp");
  ?&gt;
  </code></pre>
  
  <p>This works, but I can only get the results of the command after it has finished, which takes about 30 seconds.</p>
  
  <p>I would like to write the results to a file, <strong><em>while it is running</em></strong>, so I can poll the progress in an interval using Ajax.</p>
  
  <p>In a normal command prompt I can do </p>
  
  <pre><code>gulp &gt; results.txt 2&gt;&amp;1
  </code></pre>
  
  <p>and the text file is being filled while the command is running.</p>
  
  <p>I already tried <code>shell_exec</code>(), <code>system</code>() and <code>passthru</code>() too, but I can't get this to work from within PHP.</p>
  
  <p>Any idea's ?</p>