0

im doing an assignment where i have to make a script, and it doesn't seem to be adding to the counter to display the clues when the counter reaches a certain number Here is the code below

#!/bin/bash
#This is a game that is played by the user having to guess a number that the computer thinks of.
counter=0
# functions
function clueOne() {
 echo “The number is over 50”
 return
}
function clueTwo() {
 echo “The number is smaller than 100 and is devided by 7, 10 times”
 return
}


function selectANumber() {
 dialog --backtitle "Number Game" --title "Number Game" --infobox "Thinking of a number..." 
10 50 ; clear
}
selectANumber
# game starts here
while [ $counter  -le 10 ];  do
 read -p ”Guess my number human!”
 if [ $counter -eq 5 ]; 
 then 
 clueOne
 counter=$((counter+1))
 elif [ $counter -eq 9 ]; 
 then
 clueTwo
 counter=$((counter+1))
 elif [ $REPLY = 70 ]; 
 echo “Yes that is my number!”; 
 exit 1
 echo “Wrong number”
 counter=$((counter+1))
fi
done
echo “Sorry you ran out of attempts”
1
  • Okay thank you very much, i have encountered another problem however, it's not displaying the clues when i get to a certain amount of attempts, would you know why? Commented Nov 20, 2014 at 7:10

1 Answer 1

4

You're missing a then after this line:

elif [ $REPLY = 70 ];

Better run your script with http://www.shellcheck.net once to verify all the syntax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.