Sponsored Content
Full Discussion: change
Homework and Emergencies Homework & Coursework Questions change Post 302357331 by ripat on Tuesday 29th of September 2009 11:09:38 AM
Old 09-29-2009
There are two things, the number of tries and the running clock. The -t option of the read internal command takes care of the timout while the shell wait for the user input.

But you have to implement a general timer that will start as soon as the script starts. For that, use the date function converted in number of seconds since EPOCH. That's the idea. Try this:

Code:
#!/bin/bash
time=60
tries=3
start=$(date +%s)

left=$time
while true;do
    read -t $left -p "Code: " code
    ((tries--))
    left=$(($time-$(date +%s)+start))
    if (( $left<=0 || $tries==0 ));then
        echo "BOOOOM"
        break
    fi
    if [[ "$code" == "boom" ]];then
        echo "Correct. Bomb defused"
        break
    else
        echo "Wrong. Try again. There are $left seconds and $tries tries left."
    fi
done
exit

And.. please use the CODE tags for clarity.

Last edited by ripat; 09-29-2009 at 01:14 PM.. Reason: some fixing
 

8 More Discussions You Might Find Interesting

1. Cybersecurity

How to change ip ?

hi , Is there anyway to change ip on sco5.04 i tried using netconfig on the prompt but gives me error . how do u manually change ip cant use acoadmin and netconfig .... thx art (2 Replies)
Discussion started by: art_malabanan
2 Replies

2. Post Here to Contact Site Administrators and Moderators

Want to change my Name

Hello, Pls change my login name to Awadhesh instead of awadhesh if possible. it will be more better if it become Awadhesh Pandey. Thanks a lot. Awadhesh (2 Replies)
Discussion started by: Awadhesh
2 Replies

3. Solaris

Change IP

hello How can i change the ip address on my solaris sun 9 server ? thank you (7 Replies)
Discussion started by: pascalbout
7 Replies

4. Shell Programming and Scripting

change wc -l

Hi, I would like realize a script that it can change " wc -l" with "wc -l | sed 's/ //g'", but my problem is that i can have a pipe ,a variable ( many variable different) or a file after wc -l ?how i could test this several case ? wc -l | cut -d' ' -f1` if wc -l ${F} | awk... (1 Reply)
Discussion started by: francis_tom
1 Replies

5. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

6. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (0 Replies)
Discussion started by: ust3
0 Replies

7. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (7 Replies)
Discussion started by: ust3
7 Replies

8. SCO

How to change raid controller driver ? (hardware change)

Hello I'm trying to virtualize an instance of Sco Unix 5.0.5 in VirtualBox (called VM-A) , but sco I have problems set to launch with the new raid controller . The physical machine has a raid controller adaptec (alad driver) but VirtualBox uses buslogic (blc driver) What ... (3 Replies)
Discussion started by: flako
3 Replies
rd-bomb(6x)							XScreenSaver manual						       rd-bomb(6x)

NAME
rd-bomb - reaction/diffusion textures SYNOPSIS
rd-bomb [-display host:display.screen] [-foreground color] [-background color] [-window] [-root] [-install] [-visual visual] [-width n] [-height n] [-reaction n] [-diffusion n] [-size f] [-speed f] [-delay millisecs] [-fps] DESCRIPTION
The rd-bomb program draws reaction/diffusion textures. The code is derived from the 'd' mode of the "bomb" visual musical instrument (see http://www.cs.cmu.edu/~spot/bomb.html). I got the equations from xmorphia (http://www.ccsf.caltech.edu/ismap/image.html), which is based on a version of the Gray-Scott model taken from: John E. Pearson "Complex Patterns in a Simple System" Science, 261,189, 9 July 1993. If the frame-rate is too low, consider decreasing the width and height of the tile, or decreasing the size of the active part of the screen. OPTIONS
If one of the reaction, diffusion, radius, and palette options is set to a negative value, then that option will be set to a random appro- priate value. Be sure to try "-speed 1 -size 0.1 -epoch 3000". rd-bomb accepts the following options: -window Draw on a newly-created window. This is the default. -root Draw on the root window. -install Install a private colormap for the window. -visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -width n -height n Specify the size of the tile, in pixels. -reaction n -diffusion n These are constants in the equations that effect its visual nature. Each may be one of 0, 1, or 2. Default is -1: these constants are chosen randomly. -radius n Size of the seed. -size f What fraction of the window is actively drawn, a floating point number between 0 (exclusive) and 1 (inclusive). Default is 1.0. -speed f When a fraction of the screen is active, the active area moves at this rate (a floating point number). Default is zero. Suggested value: 1.0. -delay millisecs How many milliseconds to delay between frames; default 1, or about 1/1000th of a second. -fps Display the current frame rate and CPU load. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1), xlock(1) COPYRIGHT
Copyright (C) 1997 by Scott Draves. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, pro- vided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in sup- porting documentation. AUTHOR
Scott Draves <spot@cs.cmu.edu>, 9/97 X Version 11 5.15 (28-Sep-2011) rd-bomb(6x)
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy