HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script a timeout into a menu
Operating System - HP-UX
1827807
Members
2341
Online
109969
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
06-03-2003 05:59 AM
06-03-2003 05:59 AM
I'm trying to create a menu that will put a timeout into a menu and I'm not having much luck. If the user does not interact in 10 seconds I want the script to choose a default choice for him/her. Here is the script:
function main {
tvar=10
while [ "$tvar" >= "0" ]
do
clear
echo " ${BOLD}Main Boot Menu${NORMAL}"
echo " "
echo " Please choose on of the following"
echo " "
echo " ${BOLD}1${NORMAL} Default"
echo " ${BOLD}2${NORMAL} N-1"
echo " ${BOLD}3${NORMAL} R2"
echo " "
echo " you have ${BOLD}$tvar${NORMAL} seconds to make your selection before \"default\" is used"
sleep 1
((tvar=$tvar-1))
#done
read choice
until [ "$choice" = "1" ] || [ "$choice" = "2" ] || [ "$choice" = "3" ] ;
do
echo "Please choose one of the options above"
done
case $choice in
1)
default
;;
2)
N1
;;
3)
R2
;;
esac
done
default
}
function main {
tvar=10
while [ "$tvar" >= "0" ]
do
clear
echo " ${BOLD}Main Boot Menu${NORMAL}"
echo " "
echo " Please choose on of the following"
echo " "
echo " ${BOLD}1${NORMAL} Default"
echo " ${BOLD}2${NORMAL} N-1"
echo " ${BOLD}3${NORMAL} R2"
echo " "
echo " you have ${BOLD}$tvar${NORMAL} seconds to make your selection before \"default\" is used"
sleep 1
((tvar=$tvar-1))
#done
read choice
until [ "$choice" = "1" ] || [ "$choice" = "2" ] || [ "$choice" = "3" ] ;
do
echo "Please choose one of the options above"
done
case $choice in
1)
default
;;
2)
N1
;;
3)
R2
;;
esac
done
default
}
All paths lead to destiny
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2003 06:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2003 07:53 AM
06-03-2003 07:53 AM
Re: script a timeout into a menu
James - Thanks ... that was exactly what I was looking for. I was hoping to have a countdown clock display counting down the time remaining to make a selection but I'll take what I can get...
Here is the final script:
function main {
clear
echo " ${BOLD}Main Boot Menu${NORMAL}"
echo " "
echo " Please choose on of the following"
echo " "
echo " ${BOLD}1${NORMAL} Default - test and developement"
echo " ${BOLD}2${NORMAL} Disaster Recovery N-1 copy for `hostname`"
echo " ${BOLD}3${NORMAL} Disaster Recovery R2 copy for `hostname`"
echo " "
echo "You have 10 seconds to make a selection"
print -n "Please choose one of the options above:"
choice=`line -t 10`
until [ "$choice" = "1" ] || [ "$choice" = "2" ] ||
[ "$choice" = "3" ] || [ "$choice" = "" ] ;
do
print -n "Please choose one of the options above"
choice=`line -t 10`
done
if [ "$choice" = "" ] || [ "$choice" = "1" ] ;
then
default
elif [ "$choice" = "2" ]
then
N1
elif [ "$choice" = "3" ]
then
R2
fi
}
Here is the final script:
function main {
clear
echo " ${BOLD}Main Boot Menu${NORMAL}"
echo " "
echo " Please choose on of the following"
echo " "
echo " ${BOLD}1${NORMAL} Default - test and developement"
echo " ${BOLD}2${NORMAL} Disaster Recovery N-1 copy for `hostname`"
echo " ${BOLD}3${NORMAL} Disaster Recovery R2 copy for `hostname`"
echo " "
echo "You have 10 seconds to make a selection"
print -n "Please choose one of the options above:"
choice=`line -t 10`
until [ "$choice" = "1" ] || [ "$choice" = "2" ] ||
[ "$choice" = "3" ] || [ "$choice" = "" ] ;
do
print -n "Please choose one of the options above"
choice=`line -t 10`
done
if [ "$choice" = "" ] || [ "$choice" = "1" ] ;
then
default
elif [ "$choice" = "2" ]
then
N1
elif [ "$choice" = "3" ]
then
R2
fi
}
All paths lead to destiny
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP