2

I am trying to capture the stdin and stdout from runProcess into a string for analysis.

However, setting up the handles seems to be rather difficult. I wandered into GHC.IO.Handle, and that seems to be the logical destination, but it seems that this should be very simple.

Paul Nathan
  • 39,638
  • 28
  • 112
  • 212

1 Answers1

5

If you don't need to communicate with the process interactively, the easiest method is to use readProcess:

> readProcess "date" [] []
  "Thu Feb  7 10:03:39 PST 2008\n"

Otherwise, look at runInteractiveProcess - it starts the process and creates pipes that you can write to and read from with e.g. hPutStr/hGetLine.

Mikhail Glushenkov
  • 14,928
  • 3
  • 52
  • 65