Password Echo

  • Follow


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.

Thanks,
Marc

0
Reply marcantoniosr (10) 5/9/2007 2:46:35 AM

> -----Original Message-----
> From: Marc Soda [mailto:marcantoniosr@gmail.com]=20
> Sent: Tuesday, May 08, 2007 9:47 PM
> To: ruby-talk ML
> Subject: Password Echo
>=20
> Anyone know of a way, aside from Ruby/Password, of=20
> suppressing echo for a password prompt on a terminal?  I'm=20
> interested in *nix primarily.

curses comes to mind (Curses.noecho() would suppress the echoing of the
text)

0
Reply DPhillips (20) 5/9/2007 4:48:24 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 


0
Reply jeremy702 (271) 5/9/2007 4:56:58 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.

ruby-termios

0
Reply b.candler (2627) 5/9/2007 11:09:02 AM

On May 9, 2007, at 4:46 AM, 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.

It's trivial with HighLine.

-- fxn




0
Reply fxn (468) 5/9/2007 11:22:13 AM

On 5/9/07, Xavier Noria <fxn@hashref.com> wrote:
> On May 9, 2007, at 4:46 AM, 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.
>
> It's trivial with HighLine.
>
> -- fxn
>

Thanks all.  I was hoping that there was a way I overlooked that
didn't require any external dependencies.  However, I ended up using
ruby-termios.

Marc

0
Reply marcantoniosr (10) 5/9/2007 12:49:29 PM

> Thanks all.  I was hoping that there was a way I overlooked that
> didn't require any external dependencies.  However, I ended up using
> ruby-termios.
> 
> Marc
> 
> 

Marc--I use:

     begin
       system "stty -echo"
       @password = gets.chomp
     ensure
       system "stty echo"
     end

It turns off terminal echoing, ensuring that the script can't end before 
turning echoing back on.

Dan

0
Reply dzwell (142) 5/10/2007 7:02:33 AM

6 Replies
31 Views

(page loaded in 0.108 seconds)


Reply: