title: How to get continuous output from C in PHP
body: <p>I am having difficulties to get continuous outputs from C in PHP.</p>
  
  <p>So I have made a simple example to explain what I am trying to achieve.</p>
  
  <p>Given test.c is my C program that displays continuous outputs</p>
  
  <p>test.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int c, char **v)
  {
      int counter = 0;
      while(1)
      {
          printf("%d\n",counter);
          counter++;
          sleep(2+rand()%4);
      }
      return 0;
  }
  </code></pre>
  
  <p>Then compiled with</p>
  
  <pre><code>gcc -o test test.c 
  </code></pre>
  
  <p>C program is run in test.sh below:</p>
  
  <p>test.sh</p>
  
  <pre><code>#!/bin/sh
  
  ./test
  </code></pre>
  
  <p>Then make test.sh executable with:</p>
  
  <pre><code>chmod +x test.sh
  </code></pre>
  
  <p>Now I want to get the continuous ouptut from C in test.php</p>
  
  <p>test.php</p>
  
  <pre><code>&lt;?php
  
      shell_exec("./test.sh");
  ?&gt;
  </code></pre>
  
  <p>when run on command line client with below command nothing shows.</p>
  
  <pre><code>php test.php
  </code></pre>
  
  <p>Please how can I solve this issue.</p>