LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-01-2003, 10:56 AM   #1
Rex_chaos
Member
 
Registered: Aug 2001
Location: GD, GZ, China
Posts: 240

Rep: Reputation: 30
input password & shell


Hi all,
The following script is for password input

echo "Input password for user abc..."
stty -echo #screen the input so that no one will see what u type
read password
stty echo

Here stty -echo works well. However, I would like it outputs "*" instead of what I type or nothing. Can I? How?

Thanks
 
Old 08-01-2003, 08:52 PM   #2
slapNUT
Member
 
Registered: Jun 2001
Location: Recycle Bin
Distribution: Linux & Everything else on VirtualBox
Posts: 144

Rep: Reputation: 15
http://expect.nist.gov/example/passwdprompt

Code:
 #!/depot/path/expect

# This script prompts for a passwd from stdin while echoing *'s

# Prompt MUST be passed as argument to avoid falling into the classic
# prompt-before-echo-has-been-disabled mistake.

proc getpass {prompt} {
    set sttyOld [stty -echo raw]
    send_user $prompt

    set timeout -1
    set passwd ""

    expect {
	-re "\r" {
	    send_user \r\n
	} -re "\010|\177" {
	    if {[string length $passwd] > 0} {
		# not all ttys support destructive spaces
		send "\010 \010"
		regexp (.*). $passwd x passwd
	    }
	    exp_continue
	} -re . {
	    send_user *
	    append passwd $expect_out(0,string)
	    exp_continue
	}
    }
    eval stty $sttyOld
    return $passwd
}

puts "The password you entered was: [getpass "Password: "]"
I ran across this while reading up on expect.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
shell script + change shell && continue darkRoom Programming 6 02-25-2005 02:50 AM
cant input password on suse 8.0 pro nleber01 Linux - Newbie 11 02-07-2004 09:50 AM
script and password input Rex_chaos Linux - General 1 07-22-2003 03:04 PM
Any shell can record Keyboard input? yuzuohong Linux - General 3 03-26-2003 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration