Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-21-2004, 12:19 PM   #1
Registered: Apr 2004
Posts: 42

Rep: Reputation: 15
problem with a simple script bash


i'd like to learn to write bash scripts.
i downloaded the Bash howto and Bash Guide form the Linux doc Project. I also use documentation given by one of my teacher.

right, i'm really ar the beginning of the bash howto and i'm try a script:

OPTIONS="Hello Quit"
select opt in $OPTIONS; do
if [ "$opt" = "Quit" ]; then
echo done
elif [ "$opt" = "Hello" ]; then
echo Hello World
echo bad option

This is a really simple algo that allow user interaction by proposing a prompt so he can type Hello, Quit, or get echoed bad option if he doesn't answer one of these.
The stuff is that whatever i type Quit or Hello, i always got the bad option errot.

Actually, in my ANSI (nedit), all reserved bash words are bolt but not "opt". So it could be that the shell has changed it synthax since this dude wrote that how to....
I actually had problem with my teacher doc that says stuff as : [ $?=1 ] . this was bad synthax, as you have to put a space in around the "=".

So, would u tell me if i'm crazy, if the authors just fuck it up, if the synthax has changed, or simply if i should meet a african maraboo so i could get a "programmer grigri"!

All right Thank
Old 09-21-2004, 12:42 PM   #2
Registered: Apr 2004
Posts: 42

Original Poster
Rep: Reputation: 15
allright, later on the how to i found another way to do it, whatever it doesn't solve the "opt" problem:

echo "type in either Hello or Quit, please"
read WORD
if [ $WORD = "Quit" ]; then
echo "so by by"
elif [ $WORD = "Hello" ]; then
echo "Hello World"
echo bad option
exit 0

But why the other script doesn't work?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple bash script lp449 Linux - Networking 3 08-02-2005 05:25 PM
Simple bash script Soulful93 Programming 1 06-04-2005 08:26 PM
Simple Bash Script dmedici Programming 9 12-31-2004 04:48 AM
Help with simple bash script - please tw001_tw Linux - Software 5 12-19-2004 10:02 PM
Simple BASH script fio Linux - General 5 01-18-2003 04:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration