From: Bruno Sousa on 29 Jul 2010 16:31 Hi everyone! If I want to read a simple string from keyboard: simple_text = gets What if a password needs to be read from keyboard (commando line)? How do I mask it with asterisks? Regards, Bruno -- Posted via http://www.ruby-forum.com/.
From: James Harrison on 29 Jul 2010 16:49 > > If I want to read a simple string from keyboard: > simple_text = gets > > What if a password needs to be read from keyboard (commando line)? > How do I mask it with asterisks? Try thinking of it like this: every time a key is pressed on the keyboard, you want to: print "*" I don't have time right now to mock up an example, but that might get you started.
From: Guglielmo Fachini on 29 Jul 2010 17:25 Bruno Sousa wrote: > Hi everyone! > > If I want to read a simple string from keyboard: > simple_text = gets > > What if a password needs to be read from keyboard (commando line)? > How do I mask it with asterisks? > > Regards, > Bruno This can help you: http://stackoverflow.com/questions/133719/how-to-read-a-password-in-ruby -- Posted via http://www.ruby-forum.com/.
From: Joseph E. Savard on 29 Jul 2010 17:30 require 'rubygems' require 'highline/import' pwd = ask("Enter your password: " ) {|c| c.echo=false; c.echo='*';} puts "the password=#{pwd}" > From: Bruno Sousa <brgsousa(a)gmail.com> > Reply-To: <ruby-talk(a)ruby-lang.org> > Newsgroups: comp.lang.ruby > Date: Fri, 30 Jul 2010 05:31:21 +0900 > To: ruby-talk ML <ruby-talk(a)ruby-lang.org> > Subject: how to read password from keyboard > > Hi everyone! > > If I want to read a simple string from keyboard: > simple_text = gets > > What if a password needs to be read from keyboard (commando line)? > How do I mask it with asterisks? > > Regards, > Bruno > -- > Posted via http://www.ruby-forum.com/. >
From: Joseph E. Savard on 29 Jul 2010 17:34 c.echo=false; not needed... Only needs the c.echo='*' > > require 'rubygems' > require 'highline/import' > > pwd = ask("Enter your password: " ) {|c| c.echo=false; c.echo='*';} > > puts "the password=#{pwd}" > > >> From: Bruno Sousa <brgsousa(a)gmail.com> >> Reply-To: <ruby-talk(a)ruby-lang.org> >> Newsgroups: comp.lang.ruby >> Date: Fri, 30 Jul 2010 05:31:21 +0900 >> To: ruby-talk ML <ruby-talk(a)ruby-lang.org> >> Subject: how to read password from keyboard >> >> Hi everyone! >> >> If I want to read a simple string from keyboard: >> simple_text = gets >> >> What if a password needs to be read from keyboard (commando line)? >> How do I mask it with asterisks? >> >> Regards, >> Bruno >> -- >> Posted via http://www.ruby-forum.com/. >> > >
|
Next
|
Last
Pages: 1 2 Prev: London Ruby Contractor Needed Next: Problem with a lambda not executing immediately |