Computing.Net > Forums > Unix > (Unix - Ksh) - How do i prompt user

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.

(Unix - Ksh) - How do i prompt user

Reply to Message Icon

Name: Junes
Date: September 7, 2005 at 05:07:53 Pacific
OS: Unix
CPU/Ram: Solaris
Comment:

I want to prompt a user to enter his username and password.

bpnbat -login -info < question.txt

====question.txt====
unix
solaris.eme.com
What is your username:>
What is your password:>

I have a text file, were the first two parameters are stored and then i want to request the user to enter his username and password. The password entry needs to be hidden, so the user details are not displayed on the screen.

How can i get the user to enter his details. Simply request, i am bit rusty with my scripting.


King Regards

Junes



Sponsored Link
Ads by Google

Response Number 1
Name: Luke Chi
Date: September 7, 2005 at 06:22:09 Pacific
Reply:

echo "What is your username:> \c"
read USERNAME
stty -echo
echo "What is your password:> \c"
read PASSWORD
stty echo
echo


Luke Chi


0

Response Number 2
Name: nails
Date: September 7, 2005 at 09:53:45 Pacific
Reply:

The problem with the above solution is if the user presses interrupt, it leaves the terminal in an undefined state. I'd change:

stty -echo

to

stty -echo intr '$-'

above, I'm changing the interrupt key to something the user isn't likely to use.

Also, keep in mind that the stty is one of the most non-portable of all unix commands.


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: (Unix - Ksh) - How do i prompt user

How do I format a DOS Partition Under SC www.computing.net/answers/unix/how-do-i-format-a-dos-partition-under-sc/1938.html

How Do I Remove Unix www.computing.net/answers/unix/how-do-i-remove-unix/4606.html

How do I change Backgrounds? www.computing.net/answers/unix/how-do-i-change-backgrounds/3579.html