Last active
February 26, 2016 20:18
-
-
Save fxfactorial/b56b455e379e0a431fb2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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