开发者

Using the stdout and stdin with System.IO.runCommand

开发者 https://www.devze.com 2023-04-10 13:21 出处:网络
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 b

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 lo开发者_开发技巧gical destination, but it seems that this should be very simple.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号