Created
October 24, 2016 19:57
-
-
Save ajdawson/930ce9ce3a163057e19c96f3639016b8 to your computer and use it in GitHub Desktop.
Communicating with an ssh process in OCaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let output_command channel cmd = output_string channel (cmd ^ "\n") | |
let do_ssh_hostname () = | |
let oc_in, oc_out = Unix.open_process "ssh -T hostname" in | |
output_command oc_out "hostname"; | |
flush oc_out; | |
try | |
Printf.printf "%s\n" (input_line oc_in) | |
with | |
End_of_file -> (); | |
ignore (Unix.close_process (oc_in, oc_out)) ;; | |
let () = do_ssh_hostname () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment