Wednesday, January 27, 2010

BASH Press Enter Countdown Timer

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.

for J in `seq 10 -1 1`; do K=1; echo -n "$J ";
  read -t 1 K
  if [ "$K" != 1 ]; then
    K=2; break

echo $K
Alternately, the user could press [Ctrl][C], in which case the script terminates.

Friday, January 22, 2010

Protest Trash

There was a "respect life" protest in DC today. I think its great that all these wonderful people have the free time to trash our streets. Its too bad their respect for life doesn't include the planet's ecosystem.