From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 57B63BC69 for ; Wed, 22 Aug 2007 22:17:54 +0200 (CEST) Received: from smtp.janestcapital.com (www.janestcapital.com [66.155.124.107]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7MKHrgk022184 for ; Wed, 22 Aug 2007 22:17:53 +0200 Received: from [172.25.129.161] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id A9F1044C; Wed, 22 Aug 2007 16:17:53 -0400 Message-ID: <46CC99D4.30804@janestcapital.com> Date: Wed, 22 Aug 2007 16:17:24 -0400 From: Brian Hurt User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Luca de Alfaro Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] commands.getoutput () in ocaml? References: <28fa90930708221256t497e8356k84861abd6b2e91b8@mail.gmail.com> In-Reply-To: <28fa90930708221256t497e8356k84861abd6b2e91b8@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46CC99F1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 succint:01 opendir:01 readdir:01 wrote:01 unix:01 unix:01 caml-list:01 functions:01 short:01 output:02 output:02 python:03 library:03 Luca de Alfaro wrote: > Dear All, > > I am looking for a quick way to do the equivalent of > > s = commands.getoutput ("ls " + name + "*") > > in Ocaml. > > Unix.system does perform a call, but the output of the call is not > returned... yes, I can redirect it to /tmp/output.ocaml and then read > the file, or even go crazy and build pipes, but is there a more > elegant (read: succint) way to do it? > > Luca > If what you want is to spawn a process and redirect the I/O, the standard library is short on convience functions- in this way Ocaml is more similiar to C++/Java than it is Perl/Python/Ruby. Although the convience functions are not that hard to write. If you want to read a directory, you might want to look at Unix.opendir, Unix.readdir, etc. Brian