Computing.Net > Forums > Unix > Read in Korn Shell

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Read in Korn Shell

Reply to Message Icon

Name: DaBuggin1
Date: June 11, 2003 at 17:23:06 Pacific
OS: linux8.0
CPU/Ram: dual xeon, 2GB ram
Comment:

I have written a script to login to various network equip and perform automated functions. Is there a way to hide the input from the keyboard on read in Korn shell.

read USER?"UBR Login:"
read PASS?"UBR Password:"

Currently, when the script is run, anyone looking over your shoulder can read your password. Is there a switch to do this?

Thnx in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: DaBuggin1
Date: June 11, 2003 at 21:49:15 Pacific
Reply:

I figured out a temp solution:

echo "Your Password: "
stty -echo ; read PASS
stty echo

if anyone needs something like this, here you go. if you know of a better way, please post.


0

Response Number 2
Name: nails
Date: June 11, 2003 at 21:56:07 Pacific
Reply:

Hi:

I don't know of any way of turning off echoing without modifying the terminal driver:

!/bin/ksh

# get_passwd: This function saves the current terminal settings and
# sets the terminal to no echo and disables the interrupt key with the
# unix stty command. Enter the password and # reset original terminal settings
# with stty before returning the password to the calling script.
function get_passwd {
local password oldstty

oldstty=`stty -g`
stty -echo intr '$-'
read password
stty $oldstty
echo $password
}

echo "Get password keyboard: "
string=$(get_passwd)
echo $string

Regards,

Nails


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Read in Korn Shell

Cursor handled in korn shell. www.computing.net/answers/unix/cursor-handled-in-korn-shell/5799.html

mkdir in korn shell cgi script www.computing.net/answers/unix/mkdir-in-korn-shell-cgi-script/5347.html

escaping * in korn shell www.computing.net/answers/unix/escaping-in-korn-shell/7016.html