Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-21
3
Medium Priority
?
246 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 1000 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 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

719 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