title: How can I parse output from exec.Command while still logging in realtime to os.Stdout?
body: <p>In a small Go app I'm shelling out to run a command using the os/exec package. Currently I'm passing through the log output by setting:</p>
  
  <pre><code>cmd.Stderr = os.Stderr
  cmd.Stdout = os.Stdout
  err := cmd.Run()
  </code></pre>
  
  <p>What I'd like to do now is grab the output of the log (specifically the 2nd last line) and store that in a variable. I thought this would be as easy as changing <code>err := cmd.Run()</code> to <code>cmdOutput, err := cmd.Output()</code> and parsing the log string for the value I'm looking for - however this triggers an error saying <code>exec: Stdout already set</code>.</p>
  
  <p>I could remove the setting of <code>cmd.Stdout</code>, but I would still like the rest of the log output to be passed through the  current process the same way it is now.</p>
  
  <p>I have control over the program that I am shelling out to as well, so if there's a better way to send a JSON snippet from a child command/process to the parent Go app other than writing a file to disk, that would work too.</p>
  
  <p>Any help would be greatly appreciated - I'm a bit of a golang scrub...</p>