You can also use my process-streaming library:

   import System.Process.Streaming
   import qualified Pipes.ByteString as B
 
   -- collects stdout as a lazy ByteString
   execute (pipeo (fromFold B.toLazyM)) (shell "echo test")

It depends on the pipes ecosystem and some other stuff, however.

Here are some examples.

On Thursday, December 11, 2014 10:11:09 AM UTC+1, Ernesto Rodriguez wrote:
Dear All,

I have a program which invokes an external program via exec. I wish to capture the standard output of the program without using external (temporary) files.