Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Users = Set.Make(String)
- let just_users line =
- let i = List.hd @@ String.split line ' ' in
- match i with
- | Some x -> "User was: " ^ x
- | None -> ""
- let print_set set =
- Users.iter set (fun item -> print_endline @@ "Users on system includes: " ^ item)
- let () =
- let names = Users.empty in
- let readme = Unix.open_process_in "ps aux" in
- let rec loop line =
- let names = Users.add names @@ just_users line in
- loop (Pervasives.input_line readme) in
- try
- loop (Pervasives.input_line readme)
- with
- End_of_file -> ignore (Unix.close_process_in readme);
- print_set names
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement