TMOUT is the shell built in variable to set the timeout .
TMOUT is used in three different ways: by the read builtin command, by the select builtin, and by the interactive bash shell. If it is unset, or equal to zero, then it is ignored. If it has any positive value, then these three commands which make use of it will timeout after $TMOUT seconds.
Example:
$> cat timeout.sh
same effect can be achieved using read with -t option.
read -t 5 -p "Enter password : " pass
TMOUT is used in three different ways: by the read builtin command, by the select builtin, and by the interactive bash shell. If it is unset, or equal to zero, then it is ignored. If it has any positive value, then these three commands which make use of it will timeout after $TMOUT seconds.
Example:
$> cat timeout.sh
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash TMOUT=5 read -p "Enter password : " pass if [ $? -eq 0 ] then echo "Password is $pass" else echo "Timed out...." fi |
same effect can be achieved using read with -t option.
read -t 5 -p "Enter password : " pass