Go4Expert (http://www.go4expert.com/)
-   Unix (http://www.go4expert.com/forums/unix-forum/)
-   -   shell script (http://www.go4expert.com/forums/shell-script-t21979/)

jaydip 3May2010 14:13

shell script
my problem is like this..

when this shellscript run that time it ask a username.. if user not enter username within one minute than it show a msg like time out..... otherwise it display user successfully login...

thanks in advance ....:mad:

venami 13May2010 10:30

Re: shell script
Hi, you can use the "read" command with -t option. This would help. Please find the code below.


#! /bin/sh

echo ""
echo "Program starts..."
echo "Enter the value within 10 seconds..."

read -t 10 input # Here -t followed by 10 means, the command will wait for 10 seconds to get the input.

if [ -z $input ]
    echo "Timed out. Please try again..."
    echo "Successfully logged in..."
echo ""

All times are GMT +5.5. The time now is 17:51.