LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl password input (https://www.linuxquestions.org/questions/programming-9/perl-password-input-420060/)

jonlake 02-27-2006 10:12 AM

Perl password input
 
I am taking arguments from stdin, an LDAP username and password. How can I get the input for the password to not display on the console. Example, when you su and are prompted for the password, it doesn't display it as you type. Is there a way to do this? I haven't found anything yet.

Cheers

Matir 02-27-2006 10:32 AM

You need to switch the terminal to raw mode and disable the echoing of characters. The only way I know of to do this (in PERL) is with the curses library.

spooon 02-27-2006 12:25 PM

http://perldoc.perl.org/perlfaq8.htm...-a-password%3f

jonlake 02-27-2006 01:44 PM

Solution
 
I have figured this out. It is fairly easy, I just didn't know what I was looking for.

use Term::ReadKey;
ReadMode 2;
Get STDIN;
ReadMode 0;

DanTaylor 02-27-2006 03:59 PM

IO::Prompt is a better way to do this.
The above method will eliminate all echoing


All times are GMT -5. The time now is 03:59 PM.