- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Not allowing ENTER as an option
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 12:50 PM
тАО01-21-2005 12:50 PM
Not allowing ENTER as an option
I have written a script that asks the user for input. I want to make it so that the user cannot simply hit the ENTER key to the input to continue. How can I do this? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 03:01 PM
тАО01-21-2005 03:01 PM
Re: Not allowing ENTER as an option
while [ "X$input" = "X" ]
do
echo "Don't press enter, type something"
read input
done
I looked through stty -a, maybe defineing
stty eol does the trick, but I'm not sure.
(Wait for someone else's opinion on that)
If the users are connecting with a graphics-enabled terminal (hpterm, dtterm, putty, ...) You could use ncurses.
A friend of mine also wrote a shell widget library, but I don't find his cvs-web site right now, so no access to that, but I'll try to add it tomorrow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 06:42 PM
тАО01-21-2005 06:42 PM
Re: Not allowing ENTER as an option
I usualy do the following in sh/ksh:
while true; do
echo "Please answer "
read INP
case $INP in
A) doA;break;;
B) doB;break;;
C) doC;break;;
*) echo "Invalid answer <$INP>"
esac
done
HTH
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 11:59 PM
тАО01-21-2005 11:59 PM
Re: Not allowing ENTER as an option
Here's a simple sample:
Do you want to continue
Would you like to stop now
The funny thing is that if they are bright they could use tck/tl to fool you!
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2005 10:05 AM
тАО01-23-2005 10:05 AM
Re: Not allowing ENTER as an option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 04:34 AM
тАО01-24-2005 04:34 AM
Re: Not allowing ENTER as an option
input=""
while true
do
read input?"Please type something... "
if [[ -z $input ]]
then
echo "You cannot enter a blank line!"
else
echo "thank you"
break
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 05:13 AM
тАО01-24-2005 05:13 AM
Re: Not allowing ENTER as an option
neither my string-compare nor test -z prohibit this.
please consider a different way of doing this.
for example, /etc/default/security has the option SU_ROOT_GROUP which could be set to =wheel , then only users which are members of the wheel group will be able to become root. (wheel is the de-facto standard name for that thingy)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 08:00 AM
тАО01-24-2005 08:00 AM
Re: Not allowing ENTER as an option
stty -brkint and
stty -isig
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 01:43 PM
тАО01-24-2005 01:43 PM
Re: Not allowing ENTER as an option
As you can tell, script writing is not my "area of expertise". I do not have a trusted system (due to some software issues) and do not have a /etc/default/security file. I am also a bit unsure how to use the "stty" commands.
I did have an idea however. If I redirected a ls of /home into a file, could I write a script that will only allow them to pick something that is in that file? Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2005 02:32 PM
тАО03-02-2005 02:32 PM
Re: Not allowing ENTER as an option
echo "\n\n Please enter the user ID that you want to assume: \c"
ls /home > /tmp/TEMP
while true
do
read INPUT
[[ "a$INPUT" = "a" ]] && continue
grep -q $INPUT /tmp/TEMP
[[ $? !=0 ]] && echo "\n\n Access denied." && exit
break
done
su - $INPUT
rm /tmp/TEMP
exit
Thanks...Bob
- Tags:
- su