使用OCaml收集外部命令的输出 [英] Collecting the output of an external command using OCaml

查看:81
本文介绍了使用OCaml收集外部命令的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用外部命令并在OCaml中收集其输出的正确方法是什么?

What is the right way to call an external command and collect its output in OCaml?

在Python中,我可以执行以下操作:

In Python, I can do something like this:

os.popen('cmd').read()

如何在OCaml中获取外部程序的所有输出?或者,更好的是,带有Lwt的OCaml?

How I can get all of an external program's output in OCaml? Or, better, OCaml with Lwt?

谢谢.

推荐答案

您要 Unix.open_process_in ,在OCaml系统手册3.10版的第388页中进行了描述.

You want Unix.open_process_in, which is described on page 388 of the OCaml system manual, version 3.10.

这篇关于使用OCaml收集外部命令的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆