title: Grabbing output from exec
body: <p>I'm trying to write a C program that grabs command output and then i'll be passing that to another program.</p>
  <p>I'm having an issue, I cant work out how to get the command output and store it.  Below is a sample of what I have</p>
  <pre><code>if(fork() == 0){
     execl(&quot;/bin/ls&quot;, &quot;ls&quot;, &quot;-1&quot;, (char *)0);
     /* do something with the output here */
  }
  else{
      //*other stuff goes here*
  }
  </code></pre>
  <p>so basically im wondering if there is any way i can get the output from the &quot;execl&quot; and pass it to some thing else (e.g. via storing it in some kind of buffer).</p>
  <p>Suggestions would be great.</p>