Solved

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

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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 …
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

947 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

20 Experts available now in Live!

Get 1:1 Help Now