Solved

How in bash do I give the user 5 seconds to answer or assume " do not fix"

Posted on 2011-03-21
3
243 Views
Last Modified: 2012-05-11
I have a script.  

I want to give the user 5 seconds to type if   FIX
or it will assume you do not want to fix it and it wiill just repsond with what is broke.

0
Comment
Question by:TIMFOX123
3 Comments
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 250 total points
ID: 35181984
check this one

http://linuxcommand.org/wss0110.php
#!/bin/bash
echo -n "Hurry up and type something! > "
if read -t 5 response; then
    echo "Great, you made it in time!"
else
    echo "Sorry, you are too slow!"
fi

Open in new window

0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 250 total points
ID: 35182036
unset INPUT; read -t5 INPUT
if [ "$INPUT" = "FIX" ]
   then
     echo "Correct input entered"
     # do what's needed to fix
    else
      echo "Not fast enough!"
      # do what's needed to respond what is broke
fi

wmp
0
 

Author Closing Comment

by:TIMFOX123
ID: 35184138
you make it look too easy

thx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question