Advertisement
Guest User

Untitled

a guest
Feb 5th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. module Users = Set.Make(String)
  2.  
  3. let just_users line =
  4. let i = List.hd @@ String.split line ' ' in
  5. match i with
  6. | Some x -> "User was: " ^ x
  7. | None -> ""
  8.  
  9. let print_set set =
  10. Users.iter set (fun item -> print_endline @@ "Users on system includes: " ^ item)
  11.  
  12. let () =
  13. let names = Users.empty in
  14. let readme = Unix.open_process_in "ps aux" in
  15. let rec loop line =
  16. let names = Users.add names @@ just_users line in
  17. loop (Pervasives.input_line readme) in
  18. try
  19. loop (Pervasives.input_line readme)
  20. with
  21. End_of_file -> ignore (Unix.close_process_in readme);
  22. print_set names
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement