If TMOUT set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin. The select command terminates if input does not arrive after TMOUT seconds when input is coming from a terminal.
In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.
Below is the bash script which explains the above concept ...
Feel free to copy and use this script
Source: cat timeout.sh
#!/bin/bash
TMOUT=5
echo -n "Enter you username: "
read username
if [[ -z $username ]]; then
# No username provide
username="Not Set"
echo "Timeout, Run this script again and set your valid username..."
fi
Output: ./timeout.sh
Enter you username: Timeout, Run this script again and set your valid username...
In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.
Below is the bash script which explains the above concept ...
Feel free to copy and use this script
Source: cat timeout.sh
#!/bin/bash
TMOUT=5
echo -n "Enter you username: "
read username
if [[ -z $username ]]; then
# No username provide
username="Not Set"
echo "Timeout, Run this script again and set your valid username..."
fi
Output: ./timeout.sh
Enter you username: Timeout, Run this script again and set your valid username...
source:http://linuxpoison.blogspot.com/2012/09/13578167754921.html