| | |
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:
Solved Threads: 0
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)
#!/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
•
•
Join Date: Dec 2008
Posts: 64
Reputation:
Solved Threads: 13
Shell Scripting Syntax (Toggle Plain Text)
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
Chris F.A. Johnson
http://cfajohnson.com
http://cfajohnson.com
![]() |
Similar Threads
- Code Snippet: Multiple Pipe enabled Simple UNIX shell (C++)
- Visual C++ 2008 elapsed timer (C++)
- Text Timer (Visual Basic 4 / 5 / 6)
- What is the problem with this line of my code? (Visual Basic 4 / 5 / 6)
- Problem with a snippet of code in a shell program (C)
- Shell Function (Visual Basic 4 / 5 / 6)
Other Threads in the Shell Scripting Forum
- Previous Thread: adding a pattern after a particular line number
- Next Thread: logarithmic expression how to calculate?? Please help
| Thread Tools | Search this Thread |
Tag cloud for bomb, shellscript, timer






