problem with a simple script bash
hi!
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: #!/bin/bash OPTIONS="Hello Quit" select opt in $OPTIONS; do if [ "$opt" = "Quit" ]; then echo done exit elif [ "$opt" = "Hello" ]; then echo Hello World else clear echo bad option fi done 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 |
allright, later on the how to i found another way to do it, whatever it doesn't solve the "opt" problem:
#!/bin/bash echo "type in either Hello or Quit, please" read WORD if [ $WORD = "Quit" ]; then echo "so by by" exit elif [ $WORD = "Hello" ]; then echo "Hello World" else clear echo bad option fi exit 0 But why the other script doesn't work? guillaume |
All times are GMT -5. The time now is 04:02 AM. |