Skip to content

Instantly share code, notes, and snippets.

@fxfactorial
Last active February 26, 2016 20:18
Show Gist options
  • Select an option

  • Save fxfactorial/b56b455e379e0a431fb2 to your computer and use it in GitHub Desktop.

Select an option

Save fxfactorial/b56b455e379e0a431fb2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ocaml
(* Need topfind to make require work, need require to use podge package *)
#use "topfind"
#require "podge"
module U = Yojson.Basic.Util
let local_phones () =
Podge.Unix.read_process_output "gandalf -s"
|> Podge.List.drop ~n:5
|> String.concat ""
|> Yojson.Basic.from_string
|> U.to_list
|> List.fold_left (fun accum item -> U.(member "Local Port" item |> to_int) :: accum) []
let () =
local_phones ()
|> List.iter begin fun i ->
Printf.sprintf "Phone is on port: %d" i
|> print_endline
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment