English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
commands.getoutput () in ocaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-08-22 (20:17)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] commands.getoutput () in ocaml?
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.