Solved

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

Posted on 2011-03-21
3
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will giveā€¦
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

627 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