From: James Edward Gray II Date: 2007-01-01T00:21:53+09:00 Subject: Re: Ruby for Windows:How does one not echo keyboard input? On Dec 30, 2006, at 11:56 PM, Jason Mayer wrote: > On 12/30/06, Jacob, Raymond A Jr wrote: >> >> Firstly, I appologize if this question has already been answered >> but I >> could not figure out the >> 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? >> >> thank you, >> raymond >> >> > 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