Retrieving the integer result of a Unix command inside OCaml code

Get the length of input_channel. (There a function for that in Stdlib) Then use

really_input_string in len |> int_of_string