Stupid Ruby Tricks

J

Jacob, Raymond A Jr

------_=_NextPart_001_01C72C99.5619DC4E
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Firstly, I appologize if this question has already been answered but I =
could not figure out the=20
correct way to word my search on google to find anything relevant. I am =
running Ruby 1.8.2-15
on windows XP. I used the one-click version.
I am trying to write a script that will prompt a user for a password and =
not echo the characters back to screen.
Is this possible in the dos command window? If so then please give me a =
reference else is there an alternative
such as using TK?
=20
thank you,
raymond

------_=_NextPart_001_01C72C99.5619DC4E--
 
J

James Edward Gray II

page 791 and 792 of the ruby cookbook covers this.

require 'rubygems'
require 'highline/import'

def get_password(prompt='Password: ')
ask(prompt) { |q| q.echo = false}
end

get_password("What's your password?")

Or just:

require "rubygems"
require "highline/import"

ask("Password: ") { |q| q.echo = false }

__END__

;)

James Edward Gray II
 
J

Jacob, Raymond A Jr

------_=_NextPart_001_01C72D53.F880B2B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Jason:
Thank you,
I guess I should buy the ruby cookbook?=20
Thank you again
Raymond

________________________________

From: Jason Mayer [mailto:[email protected]]
Sent: Sun 12/31/2006 1:23 AM
To: Jacob, Raymond A Jr
Subject: Re: Ruby for Windows:How does one not echo keyboard input?



=09

Firstly, I appologize if this question has already been answered = but I=20
could not figure out the=20
correct way to word my search on google to find anything relevant. I = am
running Ruby 1.8.2-15
on windows XP. I used the one-click version.
I am trying to write a script that will prompt a user for a password = and=20
not echo the characters back to screen.
Is this possible in the dos command window? If so then please give = me a
reference else is there an alternative
such as using TK?

thank you,=20
raymond
page 791 and 792 of the ruby cookbook covers this.
=09
require 'rubygems'
require 'highline/import'
=09
def get_password(prompt=3D'Password: ')
ask(prompt) { |q| q.echo =3D false}
end
=09
get_password("What's your password?")


I don't believe this is for windows, but there's a library for it here:
=09
=09
http://www.caliban.org/ruby/ruby-password.shtml



I also had to do this to get it to work (on the off change you are as =
new as I am to ruby)
gem install highline=20



=20

------_=_NextPart_001_01C72D53.F880B2B0--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top