Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

Please refer to the original post as not all the script may be visible here.

Well, the time has come for me to have to learn shell scripting, all my efforts have gone into BAT and VBS scripting so far but I can’t avoid having to learn it now. :(

I started yesterday googleing a few sites and came across some very useful tutorials.

Today I decided to give it a go and create a small but useless shell script from scratch and see how it goes.

I wanted something that checks user input, validates it, and acts according to the input it receives. It’s for no special purpose just to act as a marker to see where I am up to.

I’m competent in C and fairly decent in Python but shell scripting seems to have a large amount of subtle differences.

I came up with this:

Code: Select all

echo -en “Please pick a number between 1 and 9:”
read number
echo “You have chose “$number”, is this correct (Yes or No)?”
read answer

#If the answer is no, ask for the number to be re-entered and re-validate the input

while [ “$answer” == “No” ]
echo -en “Please re-enter your number:”
read number
echo -en “Is this your number: “$number”? (Yes or No):”
read answer


# Once the answer is Yes, then carry on with the script

if [ “$answer” == “Yes” ]; then
echo “Ok, please wait whilst I consult my database…”

sleep 1
echo “.”
sleep 1
echo “..”
sleep 1
echo “…”
sleep 3;
echo “OK, database consulted, lets see if you won”

sleep 5
echo “.”
sleep 1
echo “..”

if [ “$number” != “3” ]; then
echo “Unlucky, that is not the magic number”


if [ “$number” == “3” ]; then
echo “Well done, you guessed it!”

What I can’t seem to do is to stop the damn thing exiting after it has completed. I want it to run until ^C is hit.

Does anyone have any ideas?

Thanks very much


By admin

Former Freehand Freelance Graphic Illustrator... been online since 2004 ( late starter ), blogging since 2005, presently writing a suspense-thriller e-book that began as a screenplay.