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
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
On 05.03.2007 14:15, Rebhan, Gilbert wrote:
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
Hi,
/*
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 [~]:
*/
How to adopt that for =
cvsrepos=%w[…]
cvspass=gets.chomp
cvsrepos.each {|x|
puts “Login CVS Repository >> #{x} …”
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
On Mar 5, 2007, at 2:15 PM, Rebhan, Gilbert wrote:
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs