caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Remi VANICAT <vanicat@labri.u-bordeaux.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Ocaml equivalent of python's
Date: 06 Feb 2002 19:15:43 +0100	[thread overview]
Message-ID: <87heouschc.dlv@wanadoo.fr> (raw)
In-Reply-To: <20020206140335.GA27734@adept.co.za>

Johann Spies <jspies@sun.ac.za> writes:

> I have tried 
> -------------------------------------------------
> #  let listing = Unix.execv "ls -laprt";;
> val listing : string array -> unit = <fun>
> # let l = Array.to_list listing;;
> This expression has type string array -> unit but is here used with
> type
>   'a array
> -------------------------------------------------

Unix.execv is a raw interface to the exec unix system call.

You should use the "High-level process and redirection management"
function :

let reading = open_process_in "ls -laprt";;

then reading is a in_channel that you can read with the General input
functions of the core library.

for example if you want the list of the line :

let rec list_of_line file_in =
  try
    let line = input_line file in in
    line :: (list_of_line file_in)
  with    
    | End_of_file -> []

but stream may be more useful than list to manipulate information
from a channel
(and the Directories function of the Unix library are more useful
than this list, if you want to know what is in a directory)
-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2002-02-06 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-06 14:03 Johann Spies
2002-02-06 18:07 ` Xavier Leroy
2002-02-07  6:30   ` Johann Spies
2002-02-06 18:15 ` Remi VANICAT [this message]
2002-02-07  9:14 ` Nicolas barnier
2002-02-08  2:20   ` Julian Assange
2002-02-08 20:29   ` Chris Hecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87heouschc.dlv@wanadoo.fr \
    --to=vanicat@labri.u-bordeaux.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).