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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

(Unix - Ksh) - How do i prompt user

Reply to Message Icon

Original Message
Name: Junes
Date: September 7, 2005 at 05:07:53 Pacific
Subject: (Unix - Ksh) - How do i prompt user
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


Report Offensive Message For Removal


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


Report Offensive Follow Up For Removal

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.


Report Offensive Follow Up For Removal







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



Results for: (Unix - Ksh) - How do i prompt user

How do I format a DOS Partition Under SC
    Summary: I have an unformatted DOS partition on my SOC Openserver 505a system. I am new to UNIX and need to know how do I format this partiton? When I type DOS at the boot: prompt I get this message: CYL OVF...
www.computing.net/answers/unix/how-do-i-format-a-dos-partition-under-sc/1938.html

How Do I Remove Unix
    Summary: I have a 30g IBM Deskstar with FreeBSD 4.x on it, however i cannot use any MSoft based format programs to fdisk or get the 30 gig hdd usuable again for Windows. How do i repartition and format a drive...
www.computing.net/answers/unix/how-do-i-remove-unix/4606.html

How do I change Backgrounds?
    Summary: I have Open Unix 8 by Caldera Software www.caldera.com How do I change the Desktop Background, there are pre-configured/installed stupied design backgrounds, but I would like to add some of my own fr...
www.computing.net/answers/unix/how-do-i-change-backgrounds/3579.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software