I have this bash script which basically starts the web and selenium servers with progress indicator. Since it takes some time to selenium server to start I\'m checking the statu
The stty invocations are from http://www.unix.com/shell-programming-and-scripting/84624-nonblocking-i-o-bash-scripts.html
This still respects Ctrl-C, but doesn't show input, and consumes it so it's not left for the shell.
#!/bin/bash
hideinput()
{
if [ -t 0 ]; then
stty -echo -icanon time 0 min 0
fi
}
cleanup()
{
if [ -t 0 ]; then
stty sane
fi
}
trap cleanup EXIT
trap hideinput CONT
hideinput
n=0
while test $n -lt 10
do
read line
sleep 1
echo -n "."
n=$[n+1]
done
echo
Use stty
to turn off keyboard input.
stty -echo
#### Ur Code here ####
stty echo
-echo
turns off keyboard input and stty echo
reenables keyboard input.