Here's a little script snippet that displays a countdown timer and determines if the user pressed
Enter. If the user does nothing, this returns 1, if the user presses
Enter, it returns 2. Ultimately, we would fork based upon the action.
#!/bin/bash
for J in `seq 10 -1 1`; do K=1; echo -n "$J ";
read -t 1 K
if [ "$K" != 1 ]; then
K=2; break
fi
done
echo $K
Alternately, the user could press [Ctrl][C], in which case the script terminates.
No comments:
Post a Comment