Jeremy Hinegardner
5/9/2007 4:57:00 AM
On Wed, May 09, 2007 at 11:46:35AM +0900, Marc Soda wrote:
> Anyone know of a way, aside from Ruby/Password, of suppressing echo
> for a password prompt on a terminal? I'm interested in *nix
> primarily.
HighLine can take care of this for you.
> cat password.rb
require "rubygems"
require "highline/import"
pass = ask("Enter your password: ") { |q| q.echo = '*' }
puts "Your password is `#{pass}'!"
> ruby password.rb
Enter your password: ********************************************
Your password is `This is how you do a password prompt in ruby'!
If you set q.echo = false then you will have nothing echoed on the
terminal.
If you want to roll your own on *nix boxes, you'll need to become
familiar with stty(1).
enjoy,
-jeremy
--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org