Please I want to build a program in scripting that will start a timer from 60 seconds and decrement every second.There should be an input where the user should be able to enter the secret password to dis-activate the timer-bomb.If the user fails to enter the correct password 3 times or the timer reaches 0 without any entries,a message should be displayed as Bomb Exploded else a message should be displayed as Bomb Defused.Beneath is the code i tried but its not working as i wish,so please help me if necessary.

#!/bin/bash



  read -t 10 -p "Code : " code

for (( i=1 ; i<=3 ; i++ )); do echo $i;

  if [ "$code" == "boom" ]; 

  then

       echo "Bomb Disactivated"

  else

       echo "Bomb Exploded"



  fi

Recommended Answers

All 2 Replies

password=boom
n=0
for n in 1 2 3
do
  read -ep "Code: " code
  [ "$code" = "$password" ] && break
done

if [ "$code" = "$password" ]
then
  echo "Bomb Disactivated"
else
  echo "Bomb Exploded"
fi

thanks it helped

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.