mask gets_chomp ?

  • Thread starter Rebhan, Gilbert
  • Start date
R

Rebhan, Gilbert

Hi,

i have a script that uses a password as input.

The password is provided via gets_chomp
in the shell.

Is there a way to mask the password with *
or do i have to write a gui for that ?


Regards, Gilbert
 
R

Robert Klemme

Hi,

i have a script that uses a password as input.

The password is provided via gets_chomp
in the shell.

Is there a way to mask the password with *
or do i have to write a gui for that ?

Maybe you can do that via curses. Other than that, you could use "stty
-echo" before and "stty echo" after the password input:

14:50:07 [~]: ruby -e 'system("stty", "-echo")
puts "enter!"
pass=gets.chomp
puts "You entered #{"*" * pass.size}"
system("stty", "echo")'
enter!
You entered ******
14:50:56 [~]:

Kind regards

robert
 
R

Rebhan, Gilbert

=20
Hi,

/*
14:50:07 [~]: ruby -e 'system("stty", "-echo")
puts "enter!"
pass=3Dgets.chomp
puts "You entered #{"*" * pass.size}"
system("stty", "echo")'
enter!
You entered ******
14:50:56 [~]:
*/


How to adopt that for =3D

cvsrepos=3D%w[...]
cvspass=3Dgets.chomp

cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
:pserver:#{ENV["USERNAME"]}:#{cvspass}@cvshostd:/cvsrepos/#{x} login")
}
puts "Login successful !!"


the password is readable in the cmd shell

Regards, Gilbert
 
X

Xavier Noria

i have a script that uses a password as input.

The password is provided via gets_chomp
in the shell.

Is there a way to mask the password with *
or do i have to write a gui for that ?

Just in case, are you aware of HighLine's ask mehod?

require 'rubygems'
require 'highline/import'

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

-- fxn
 

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

No members online now.

Forum statistics

Threads
474,235
Messages
2,571,181
Members
47,818
Latest member
KazukoXea6

Latest Threads

Top