Bomb timer and secret code in shell

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Sep 2009
Posts: 9
Reputation: frankycool is an unknown quantity at this point 
Solved Threads: 0
frankycool frankycool is offline Offline
Newbie Poster

Bomb timer and secret code in shell

 
-1
  #1
Oct 1st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 64
Reputation: cfajohnson is an unknown quantity at this point 
Solved Threads: 13
cfajohnson cfajohnson is offline Offline
Junior Poster in Training

Re: Bomb timer and secret code in shell

 
0
  #2
Oct 4th, 2009
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
Chris F.A. Johnson
http://cfajohnson.com
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 9
Reputation: frankycool is an unknown quantity at this point 
Solved Threads: 0
frankycool frankycool is offline Offline
Newbie Poster

Re: Bomb timer and secret code in shell

 
0
  #3
Oct 4th, 2009
thanks it helped
Reply With Quote Quick reply to this message  
Reply

Tags
bomb, shellscript, timer

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for bomb, shellscript, timer
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC