Google Groups Home
Help | Sign in
ENTERING PASSWORD: ****** ???
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joseph Suriol  
View profile  
 More options Jan 20 1999, 3:00 am
Newsgroups: comp.unix.shell
From: "Joseph Suriol" <tigl...@usa.net>
Date: 1999/01/20
Subject: ENTERING PASSWORD: ****** ???
The script

print
stty -echo
read -r pw?"Enter password: "
stty echo
print

does the job.  But, is there a way to have an asterisk appear for each
password character typed?

It is easy in C putting the terminal in cbreak mode, but in ksh seems
impossible.

I am using ksh93

Thanks


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Mercer  
View profile  
 More options Jan 20 1999, 3:00 am
Newsgroups: comp.unix.shell
From: damer...@mmm.com (Dan Mercer)
Date: 1999/01/20
Subject: Re: ENTERING PASSWORD: ****** ???
In article <785fad$qr...@winter.news.rcn.net>,

read will only return after getting a newline.  The -r option only
affects how backslash-newline sequences are to be treated,  it does
not do a raw read.  

You could either:

function savetty
{
SAVETTY=$(stty -g </dev/tty)

}

function rawtty
{
stty raw -echo </dev/tty

}

function cookedtty
{
stty ${SAVETTY:-cooked} </dev/tty

}

function getpass
{
typeset
savetty
rawtty
typeset -n passwd=${1:-PASSWD}
typeset ans
while :
    do
    ans=`dd if=/dev/tty count=1 bs=1 2>/dev/null`
    case $ans in
       $'\n') break;;
       $'\b') [[ -n $passwd ]] && {
                 passwd="${passwd%?}"
                 print -n "\b \b"
                 }
              ;;
           *) passwd="${passwd}${ans}";print -n "*";;
    esac
    ((${#passwd}>8)) && { print -n "\a";break; }
    done

cookedtty

}

[[UNTESTED]]

or create a builtin

Dan Mercer

damer...@uswest.net

Opinions expressed herein are my own and may not represent those of my employer.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John DuBois  
View profile  
 More options Jan 22 1999, 3:00 am
Newsgroups: comp.unix.shell
From: spce...@deeptht.armory.com. (John DuBois)
Date: 1999/01/22
Subject: Re: ENTERING PASSWORD: ****** ???
In article <785fad$qr...@winter.news.rcn.net>,

Joseph Suriol <tigl...@usa.net> wrote:
>The script

>print
>stty -echo
>read -r pw?"Enter password: "
>stty echo
>print

>does the job.  But, is there a way to have an asterisk appear for each
>password character typed?

>It is easy in C putting the terminal in cbreak mode, but in ksh seems
>impossible.

If the OS you're using has a facility equivalent to mapchan, try that.
I use e.g.

[set up traps to unmap channel on interrupt]
mapchan -f hide.map
read -r password
mapchan -n

where hide.map contains:

# Erase, newline, cr, and ^G are not hidden because the shell may emit them.
output
1 '*'
2 '*'
3 '*'
4 '*'
5 '*'
6 '*'
7 7
8 8
9 '*'
10 10
11 '*'
12 '*'
13 13
14 '*'
...
255 '*'

        John
--
John DuBois    spce...@armory.com.    KC6QKZ   http://www.armory.com./~spcecdt/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google