title: Capture both exit status and output from a system call in R
body: <p>I've been playing a bit with <code>system()</code> and <code>system2()</code> for fun, and it struck me that I can save either the output or the exit status in an object. A toy example:</p>
  
  <pre><code>X &lt;- system("ping google.com",intern=TRUE)
  </code></pre>
  
  <p>gives me the output, whereas</p>
  
  <pre><code>X &lt;- system2("ping", "google.com")
  </code></pre>
  
  <p>gives me the exit status (1 in this case, google doesn't take ping). If I want both the output and the exit status, I have to do 2 system calls, which seems a bit overkill. How can I get both with using only one system call?</p>
  
  <p>EDIT : I'd like to have both in the console, if possible without going over a temporary file by using <code>stdout="somefile.ext"</code> in the <code>system2</code> call and subsequently reading it in.</p>