Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using a ksh "read" to echo to stdout and not the screen

267 views
Skip to first unread message

William Niesz

unread,
Sep 1, 1995, 3:00:00 AM9/1/95
to
How would I do the following example:

echo 'Enter Password:"
read password
echo 'Verifying......."
(etc...)

The purpose is to have the command 'read' echo the password to /dev/null or a
file (doesn't matter). I just do not want to display the "password" when the
user types it in on the screen.

read password > file
and
read password 1>&1 do not work as whatever the user types will still display
on the screen.

I am probably overlooking something very simple but I can't seem to figure it
out. Any help would be appreciated.

This system is a ksh running SCO UNIX 3.2v4.2

TIA


Rich

unread,
Sep 1, 1995, 3:00:00 AM9/1/95
to

Turns out to be simple, but not obvious.

Try this...

print
print -n "Supervisor: "
read SUP
print -n "Password: "
stty -echo
read PASSWD
stty echo


This is from a ksh script, so you might not want to use the print
command.

Rich

dba...@support1.ebay.sun.com

unread,
Sep 1, 1995, 3:00:00 AM9/1/95
to

In article 0000...@crpl.cedar-rapids.lia.ia.us, nie...@crpl.cedar-rapids.lia.ia.us (William Niesz) writes:
>How would I do the following example:
>
>echo 'Enter Password:"
Try using stty -echo
>read password
stty echo

hal...@caip.rutgers.edu

unread,
Sep 1, 1995, 3:00:00 AM9/1/95
to
In article <nieszw.2...@crpl.cedar-rapids.lia.ia.us>, nie...@crpl.cedar-rapids.lia.ia.us (William Niesz) writes
> ....

> The purpose is to have the command 'read' echo the password to /dev/null or a
> file (doesn't matter). I just do not want to display the "password" when the
> user types it in on the screen.
> ....

> I am probably overlooking something very simple but I can't seem to figure
> it out. Any help would be appreciated.

Not simple; in general the shells nowize support such usage. If your shell
doos, you are luckie. If not, then uze "stty" (code not tested!):
old=`stty -g`
stty -echo
read pswd
stty $old

Peter Turnbull

unread,
Sep 13, 1995, 3:00:00 AM9/13/95
to
>echo 'Enter Password:"
>read password
>echo 'Verifying......."
>(etc...)
>
>The purpose is to have the command 'read' echo the password to /dev/null or a
>file (doesn't matter). I just do not want to display the "password" when the
>user types it in on the screen.
>
>read password > file
>and
>read password 1>&1 do not work as whatever the user types will still display
>on the screen.
>

You need to turn echo off when the person puts their password in, eg:

echo "Enter Password: \c"

0 new messages