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
[Caml-list] Unix.create_process
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-12-20 (12:25)
From: Rolf Wester <wester@i...>
Subject: [Caml-list] Unix.create_process

I want to start a process and read the stdout channel of this process.
I tried:

let instring = String.create 10 in
    let pid = Unix.create_process ~prog:"ls" ~args:[|"/usr"|] 
			~stdin:Unix.stdin ~stdout:Unix.stdin ~stderr:Unix.stderr in
    let nread = Unix.read Unix.stdin ~buf:instring ~pos:0 ~len:10 in instring;;

but this one waits for keyboeard input instead of reading the output of ls.
When I type  ~stdout:Unix.stdout instead of  ~stdout:Unix.stdin the ls 
output is written to stdout (as expected).

Can anybody tell me what I made wrong?

Thanks in advance.

Rofl Wester 

Rolf Wester
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