Shell Script taking Time bound Input !!
Here is a simple shell script that will take the input from user keyboard and displays it on the screen. But the idea is not that!!!
Idea is to show you, how to take “time bound” input for sensitive information.
and here is the script…
#taking time bound input
TIMEOUTLIMIT=4 # 4 seconds of wait
echo “type something ”
read -t $TIMEOUTLIMIT first <&1
if [ -z “$first” ]
echo “timed out.. sorry”
echo “you typed $first”
exit 0 # exit clean
When you execute this script using “sh time_bound.sh” and give some input within the time frame of 4 seconds it will be displayed.. else the script will exit cleanly after waiting for 4 seconds. As shown: