#!/usr/local/bin/bash
# Runs the RUN_PROG
# LOOPS number of times
# at SLEEP_TIME second intervals.
#
# ottrey@ripe.net Tue Jun  1 15:08:51 MET DST 1999

loops=30
sleep_time=2
run_prog='/usr/local/mysql/bin/mysqladmin --user=root --password=admin processlist'

while [ $# -ge 1 ]; do
  case $1 in
  -l*)    loops=`echo $1 | cut -c3-`;;
  -l)     shift;  rate=$1 ;;
  -s*)    sleep_time=`echo $1 | cut -c3-`;;
  -s)     shift;  sleep_time=$1 ;;
  -r*)    run_prog=`echo $1 | cut -c3-`;;
  -r)     shift;  run_prog=$1 ;;
  -c)     shift;  no_clear=1 ;;
  esac

  shift
done

echo loops=$loops
echo sleep_time=$sleep_time

while [ $loops != 0 ];
do
  sleep $sleep_time
  if [ $no_clear ]; then echo ""; else clear; fi
  $run_prog
  loops=$(($loops-1))
  echo $loops
done

