![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| check input = "empty" and "numeric" | geoffry | Shell Programming and Scripting | 6 | 12-13-2007 05:12 AM |
| Breaking input with "read" command | vino | Shell Programming and Scripting | 2 | 08-04-2005 01:10 PM |
| how to request a "read" or "delivered" receipt for mails | plelie2 | Shell Programming and Scripting | 1 | 08-06-2002 04:26 PM |
| Which is the most "standard" platform to learn? | PointNClickGuy | UNIX for Dummies Questions & Answers | 5 | 10-01-2001 12:54 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
Code:
#!/bin/sh
#
STTY=`stty -g`
WAIT=60
printf 'enter [y/n] '
stty intr '' -icanon min 0 time $WAIT ignbrk -brkint -ixon isig
read ans
stty $STTY
case ${ans:=y} in [yY]*) ;; *) exit ;; esac
echo do the rest
exit
Last edited by vgersh99; 03-02-2005 at 04:49 PM.. |
|
||||
|
You can use read timeout functionality to do this. We can make your requirement as,
Code:
#!/bin/sh # input timeout echo "Enter your input" read -t 5 input if [[ $? -ne 0 ]] then echo "User did not enter any input" exit 1 else echo "User did input as $input" fi exit 0 # END # HTH. |
|
||||
|
[QUOTE=vgersh99]
Code:
#!/bin/sh
#
STTY=`stty -g`
WAIT=60
printf 'enter [y/n] '
stty intr '' -icanon min 0 time $WAIT ignbrk -brkint -ixon isig
read ans
stty $STTY
case ${ans:=y} in [yY]*) ;; *) exit ;; esac
echo do the rest
exit
I am on an IBM p570 with AIX 5.3 and when for some reason I can only get a time delay of 20 seconds. If I use WAIT=200 I get twenty seconds as would be expected, however when I use WAIT=300 I get 4 seconds. Can anyone explain this to me? Thanks |
|
||||
|
Quote:
![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|