Quick question. How to run an executable in ocaml? I believe that this is possible, but I do not know how to do it.
Provide sample code.
If you just want to run the program and not communicate with it, use Sys.command.
Sys.command
let exit_code = Sys.command "c:\\path\\to\\executable.exe /argument" in (* if exit_code=0, the command succeeded. Otherwise it failed. *)
For more complex cases, you need to use the functions in the moduleUnix . Despite the name, most of them work under Windows. For example, if you need to get the result from the command:
Unix
let ch = Unix.open_process_in "c:\\path\\to\\executable.exe /argument" in try while true do let line = input_line ch in β¦ done with End_of_file -> let status = close_process_in ch in β¦