caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Issac Trotts <ijtrotts@ucdavis.edu>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] uname for Ocaml
Date: Tue, 21 Jan 2003 12:29:55 -0800	[thread overview]
Message-ID: <20030121202955.GA5938@beech> (raw)
In-Reply-To: <15917.26071.995917.528195@hector.lesours>

An alternative would be to use

  #load "unix.cma"

  let uname() =                                                      
    let (inc, outc) = Unix.open_process "uname" in  
    let name = input_line inc in                  
    close_in inc;
    close_out outc;
    name;;

Here's a more general way to capture the stdout of a Unix call:

  let syscall cmd =                                    
    let (inc, outc) = Unix.open_process cmd in  
    let buf = Buffer.create 16 in                       
    (try while true do Buffer.add_channel buf inc 1 done with _ -> ());
    close_in inc;
    close_out outc;
    Buffer.contents buf;;

Issac


On Tue, Jan 21, 2003 at 04:23:03PM +0100, Basile STARYNKEVITCH wrote:
> Dear All,
> 
> If you need to call uname(2) from some Ocaml program you can steal my
> tiny code in util.ml util.mli util_ml.c on
> 
> http://www2.poesia-filter.org:8000/cgi-bin/cvsweb.cgi/PoesiaSoft/PoesiaMonIcap/
> 
> I actually wish that uname(2) will be incorporated in the Unix module.
> 
> regards
> -- 
> 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
> email: basile<at>starynkevitch<dot>net 
> alias: basile<at>tunes<dot>org 
> 8, rue de la Fa?encerie, 92340 Bourg La Reine, France
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

-- 
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-01-21 20:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-21 15:23 Basile STARYNKEVITCH
2003-01-21 20:29 ` Issac Trotts [this message]
2003-01-21 20:53   ` Basile STARYNKEVITCH
2003-01-21 22:42     ` Issac Trotts
2003-01-22 16:47 ` [Caml-list] " Michaël Grünewald
2003-01-24 10:36   ` Michal Moskal

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=20030121202955.GA5938@beech \
    --to=ijtrotts@ucdavis.edu \
    --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).