I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?
What exactly are you intending to do? Do you want to run it and forget about it? Then do a fork/exec. Do you want run it and wait until it's finished but otherwise do nothing? Then use Sys.command. Do you want to read/write to it? Then uses Unix.open_process* (or Unix.create_process*).
For example, if I want to run ls and print out the results, I can do this:
let ls = Unix.open_process_in "ls"
try
while true do
Printf.printf "%s\n" (input_line ls)
done
with End_of_file -> ()
Unix.close_process_in ls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With