Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] How to read a password without displaying it?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-02-07 (15:12)
From: David MENTRE <dmentre@l...>
Subject: Re: [Caml-list] How to read a password without displaying it?
Hello Alain, writes:

> The field c_echo in the record type Unix.terminal_io might be the
> solution.

Thanks a lot Alain, you found the right solution.

Here is the working code:

open Unix
let read_password () =
  let term_init = tcgetattr stdin in
  let term_no_echo = { term_init with c_echo = false; } in
  tcsetattr stdin TCSANOW term_no_echo;
  let password = read_line () in
  tcsetattr stdin TCSAFLUSH term_init;

Many thanks,
 David Mentré <>

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: