- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How do I ask a question in ksh and proceed acc...
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
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
тАО04-01-2005 03:54 AM
тАО04-01-2005 03:54 AM
How do I ask a question in ksh and proceed accordingly?
"Do you want to continue?"
and if answers "yes", then continue.
I'm just drawing a blank here. How do I do that:
print "question"
read "answer"
check response? Will the read wait for the answer? Do I have to do something special? Can I time out the read response if he does't answer in 5 minutes?
- Tags:
- read
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2005 04:00 AM
тАО04-01-2005 04:00 AM
Re: How do I ask a question in ksh and proceed accordingly?
simple script, you can use "if" instead of case
#!/usr/bin/ksh
print "Do you want to continue?"
read ans
case "$ans" in
"yes")
print "Answer is yes"
;;
"no")
print "Answer is no"
;;
*)
print "Wrong answer"
;;
esac
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2005 04:01 AM
тАО04-01-2005 04:01 AM
Re: How do I ask a question in ksh and proceed accordingly?
Standard technique is something like:
echo "question"
read "answer"
(test answer)
I suppose you could test the answer for null, sleep 60, retest, something like that.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2005 04:10 AM
тАО04-01-2005 04:10 AM
Re: How do I ask a question in ksh and proceed accordingly?
##
# Script to read an answer to a question..
#
read ANSWER?"Do you want to vgexport live VGs (yes/no): "
typeset -l LOW_ANSWER=$ANSWER
if [[ $LOW_ANSWER != "yes" ]]
then
print "You didn't enter 'yes'. Script will exit without vgexport."
print "If you want to vgexport VGs, run script again and answer 'yes'."
exit 1
fi
# Answer was yes. vgexport
print "You answered 'yes'. vgexports will run right now."
print "vgexport successfully run!"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2005 04:38 AM
тАО04-01-2005 04:38 AM
Re: How do I ask a question in ksh and proceed accordingly?
# Script to read an answer to a question..
#
typeset -l ANSWER
read ANSWER?"Do you want to vgexport live VGs (yes/[no]): "
case $ANSWER in
y* ) print "You answered 'yes'. vgexports will run right now."
#...insert your vgexport code...
print "vgexport successfully run!"
;;
* ) print "You didn't enter 'yes'. Script will exit without vgexport."
print "If you want to vgexport VGs, run script again and answer 'yes'."
exit 1
;;
esac
The pattern matching in case allows for simpler tests for various answers: y ye yes yessir! and so on.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2005 07:14 AM
тАО04-06-2005 07:14 AM