Method: Jamf::Utility#prompt_for_password

Defined in:
lib/jamf/utility.rb

#prompt_for_password(message) ⇒ String

Prompt for a password in a terminal.

Parameters:

  • message (String)

    the prompt message to display

Returns:

  • (String)

    the text typed by the user



612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/jamf/utility.rb', line 612

def prompt_for_password(message)
  begin
    $stdin.reopen '/dev/tty' unless $stdin.tty?
    $stderr.print "#{message} "
    system '/bin/stty -echo'
    pw = $stdin.gets.chomp("\n")
    puts
  ensure
    system '/bin/stty echo'
  end # begin
  pw
end