将 stdout 和 stdin 与 System.IO.runCommand 一起使用
我试图从 runProcess 转换为字符串进行分析。
然而,设置手柄似乎相当困难。我走进了 GHC.IO.Handle,这似乎是合乎逻辑的目的地,但似乎这应该非常简单。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不需要与进程交互通信,最简单的方法是使用
readProcess
:否则,查看
runInteractiveProcess
< /a> - 它启动进程并创建管道,您可以使用例如hPutStr
< /a>/hGetLine
。If you don't need to communicate with the process interactively, the easiest method is to use
readProcess
:Otherwise, look at
runInteractiveProcess
- it starts the process and creates pipes that you can write to and read from with e.g.hPutStr
/hGetLine
.