Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Answer: How do I make password prompts not echo back the user?

( #301453=categorized answer: print w/ replies, xml ) Need Help??

Q&A > input and output > How do I make password prompts not echo back the user? contributed by Anonymous Monk

Here's how I did it using Term::Readkey

ReadMode ('noecho');
print "Enter Password: ";
chomp($pw = <STDIN>);
ReadMode ('restore');

  • Comment on Answer: How do I make password prompts not echo back the user?
Replies are listed 'Best First'.
Re: Answer: How do I make password prompts not echo back the user?
by batkins (Chaplain) on Oct 23, 2003 at 02:54 UTC
    Another methood is this:
    system('stty -echo'); print "Enter Password: "; chomp($pw = <STDIN>); system('stty echo');

    The computer can't tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows. - Frank Zappa

       This works but there are two caveats you should bear in mind:

      • If you're running the script as a priviledged process you might have just opened yourself to a local attack, if the user can modify their path and slip in a trojan 'stty' binary.
      • This fails utterly on Windows, amongst other systems.
      Steve
      ---
      steve.org.uk
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2016-06-26 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (330 votes). Check out past polls.