-
Senior Member
registered user
As UnderSxore explains, changing my script to a "conditional" while do loop, will allow easier exiting, other than the CTL-C issue... From what you stated, my assumption was you didnt want to change the script, just 1 ) make it work, 2 ) make it repeat "indeffinately"...
If you take UnderScore's idea, and my changes to your script, here is what it would look like:
Code:
#!/bin/bash
# Seed the exit condition with false...
ExitCondition="no"
# Loop your script while the exit condition is still false...
while [ $ExitCondition == "no" ] ;
do
# Output our menu selections...
echo -n "
How are you feeling?
Tired
Bored
Hungry
-=-=-=-=-=-
Leave to exit script
Enter: " #Type how you feel
# Get the users input...
read OPTION
# Begin our interogation of the users input...
case $OPTION in
tired)
echo "You should get some rest."
;;
bored)
echo "Play a game of Frozen Bubble."
;;
hungry)
echo "Order pizza!"
;;
leave)
echo "Hope you are feeling better now."
# User wants to exit, change our exit condition to true...
ExitCondition="yes"
;;
*)
# User has made an entry that doesnt contain any of the tests we are looking for...
# ... Output a message that they entered something that is invalid, and what they
# entered...
echo "Invalid entry: $OPTION!"
;;
esac
done
I changed your script a little, took out the "if" statements completely, and added comments to explain more...
Hope this helps,
Ms. Cuddles
Similar Threads
-
By sibtay in forum Customising & Remastering
Replies: 4
Last Post: 10-25-2004, 11:08 AM
-
By dehahn in forum General Support
Replies: 4
Last Post: 10-16-2004, 01:31 AM
-
By Salzi in forum General Support
Replies: 1
Last Post: 09-09-2004, 02:56 AM
-
By Guitarplaya512 in forum General Support
Replies: 5
Last Post: 03-14-2004, 11:03 AM
-
By michaelmontagne in forum General Support
Replies: 1
Last Post: 09-04-2003, 09:17 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

OPNsense Firewall VPN QAT 8-Core Atom C3758 2.20GHz 16GB DDR4 128GB SSD 8xNIC
$175.00

Ubuntu Server 26.04.1 LTS Bootable USB Flash Drive – Latest September 2026
$12.99

OPNsense pfSense 8-Core Atom C3758 2.2GHz 8GB DDR4 64GB SSD 8x NIC QAT AES VPN
$115.00

Novell SUSE Linux Enterprise Server 9, Linux Professional 8.2 / 9.1 — 3 DVD Set
$58.00

Start9 Server Pure 32GB 4TB Intel i7 Node StartOS — Box + PSU
$649.00

RED HAT ENTERPRISE LINUX 5 SERVER RHF0382US-R1 for PC x86 AMD 64 INTEL 64 30 Day
$188.24

ZimaBoard 2 1664 Home Server 16GB
$350.00

All New Ubuntu 26.04 LTS Linux Bootable USB Flash Drive
$15.95

SQL Server 2022 Enterprise 96 Core License & DVD Unlimited CALs with CoA
$284.99

Microsoft SQL Server 2019 Enterprise 40 Core Unlimited CAL Retail License FPP
$299.00