Solved

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

Posted on 2011-03-21
3
239 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now