I’m trying to replace a bunch of bash script with OCaml but I have difficulties getting the output of external commands.
Here is my simple script:
#!/usr/bin/env utop open Unix;; let print_chan channel = let rec loop () = let () = print_endline (input_line channel) in loop () in try loop () with End_of_file -> close_in channel;; let () = let (ocaml_stdout, ocaml_stdin, ocaml_stderr) = Unix.open_process_args_full "echo" [| "echo"; "foo" |] (Unix.environment ()) in close_out ocaml_stdin; print_chan ocaml_stdout; print_chan ocaml_stderr; print_endline "terminado!";
I am using utop as the toplevel to have access to common modules such as Unix.
Unfortunately, my script does not print anything except “terminado!”. I’d like to get the output of