944,068 Members | Top Members by Rank

Ad:
Oct 1st, 2009
-1

Bomb timer and secret code in shell

Expand Post »
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.

Shell Scripting Syntax (Toggle Plain Text)
  1.  
  2. #!/bin/bash
  3.  
  4.  
  5.  
  6. read -t 10 -p "Code : " code
  7.  
  8. for (( i=1 ; i<=3 ; i++ )); do echo $i;
  9.  
  10. if [ "$code" == "boom" ];
  11.  
  12. then
  13.  
  14. echo "Bomb Disactivated"
  15.  
  16. else
  17.  
  18. echo "Bomb Exploded"
  19.  
  20.  
  21.  
  22. fi
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
frankycool is offline Offline
15 posts
since Sep 2009
Oct 4th, 2009
0

Re: Bomb timer and secret code in shell

Shell Scripting Syntax (Toggle Plain Text)
  1. password=boom
  2. n=0
  3. for n in 1 2 3
  4. do
  5. read -ep "Code: " code
  6. [ "$code" = "$password" ] && break
  7. done
  8.  
  9. if [ "$code" = "$password" ]
  10. then
  11. echo "Bomb Disactivated"
  12. else
  13. echo "Bomb Exploded"
  14. fi
Reputation Points: 25
Solved Threads: 23
Junior Poster
cfajohnson is offline Offline
193 posts
since Dec 2008
Oct 4th, 2009
0

Re: Bomb timer and secret code in shell

thanks it helped
Reputation Points: 10
Solved Threads: 0
Newbie Poster
frankycool is offline Offline
15 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: adding a pattern after a particular line number
Next Thread in Shell Scripting Forum Timeline: logarithmic expression how to calculate?? Please help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC