Advertisement
Guest User

Untitled

a guest
May 15th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. open Core.Std
  3.  
  4.  
  5. let () =
  6. let module Users = Set.Make(String) in
  7. let ic = Unix.open_process_in "ps aux" in
  8. let lines = In_channel.input_lines ic in
  9. let names_list = List.map lines ~f:(fun line ->
  10. let split_list = String.split line ~on:' ' in
  11. List.hd_exn split_list) in
  12. let users = Users.of_list names_list in
  13. let peeps = List.fold_right (Users.to_list users) ~f:(fun new_name old_string ->
  14. new_name ^ ":" ^ old_string)
  15. ~init:"" in
  16. print_endline @@ "User Accounts on this machine: \n" ^ peeps;
  17. ignore @@ Unix.close_process_in ic;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement