#!/bin/sh	
#v ghostrepeater v. 1.0 by duus        (May 18, 2008)
#v   location: http://thedu.us/scripts/THISSIR/ghostrepeater
#h ghostrepeater script by duus

##################################################### VERSION INFO
#v ghostrepeater, ghostrepeater X Y runs Y every X minutes, v 0.1, by duus
#v
#v 	  type <ghostrepeater help> for more information
#v    or open source code with a text editor and read it:
#v    http://thedu.us/scripts/ghostrepeater/ghostrepeater/
#v
###################################################### INSTALL INFO
#i How to install ghostrepeater
#i  1. put the ghostrepeater bash script on your path (for example, ~/bin/)
#i  2. navigate to that directory
#i  3. type "chmod +x ghostrepeater" to make the script executable
#i  4. open the ghostrepeater script with your favorite text editor (pico ghostrepeater, for example)
#i  5. Navigate to the line called #SETTINGS
#i  6. Adjust settings as necessary.  Save the file.
#i  7. type "ghostrepeater help" for usage information
#i
###################################################### SETTINGS
# general settings; name and location of this script, for self-referencing.
_SCRIPT_NAME=ghostrepeater            
_SCRIPT_LOCATION=~/bin           
# you can also hardcode if you would like.  For example, your own bin:
# _SCRIPT_LOCATION=~/bin
# or, if you are running reuben, you can access reuben's bin:
# _SCRIPT_LOCATION=~/.reuben/.bin/
# don't forget that this program is merely a text file, and you must make 
#   it executable, regardless of where you place it.
# Script_Location is used in the standard functions, below.
#
###################################################### STD, FUNCTIONS (help, version, install)
#  (h)elp, (v)ersion, and (i)nstall are standard.  I do not recommend changing them.
#    Reading them, on the other hand, to see how they work is encouraged.
#    Feel free to add another standard function.  If you do, please let me know if it is useful,
#     and whether you would mind if I included it in the standard code, with credit for you
#     in comments.  (Or an about section?  .... hmmmm)
#    These functions allow the output of the standard functions to be 
#    hardcoded into the source code.  (See #i and #v above for examples.) 
#
if [ "$1" = "version" -o "$1" = "v" ]                
	then   
	grep "^#v" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more                              
	exit 1;
elif [ "$1" = "help" -o "$1" = "h" ]
	then
	grep "^#h" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more
	exit 1;
elif [ "$1" = "install" -o "$1" = "i" ]
	then
	grep "^#i" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more
	exit 1;
elif [ "$1" = "src" ]
	then
	echo "source code of ${_SCRIPT_NAME}, a duusscript"
	echo ""
	more $_SCRIPT_LOCATION/${_SCRIPT_NAME}
	exit 1;
fi 
#
#  don't understand how this works?  see http://thedu.us/scripts/duushelp/ or run duushelp.sh
#
################################################################
#---------------------------------------------------------#
# begin ghostrepeater   (May 18, 2008)
# --------------------------
if [ "$1" = "" ]
        then
		${_SCRIPT_NAME} help;
		exit 1;
fi
#h ghostrepeater <num> <command>
#h   runs <command> every <num> minutes.
_mins=$1;
shift;
echo "  run $*  every ${_mins} minutes"
$*
_date=`nicedate`
while [ "`nicedate`" = "${_date}" ]; do
        runlater s mins ${_mins} $*
done

# --------------------------
# <tt>                 :               end ghostrepeater
#                      . 
#            ...---.,o8:i__,8Pd8   
#         _//      `"' :  d8'",8d8   
#       ,/''  vVv      . dP   b8P.8|
#      ./;|  d^_^b     .     ,P O||]
#       |||  duus@thedu.us\     |||| 
#       |||  duus.thedu.us/      || 
#       ||\            .        /_' 
#        ;+,           :       |\8
#          '.`>+.     _./'_/2/b/_
#           '-oh\._.._j:;'`P;8/,
#              `'->:o:.:src/='
#                      :    
#                      :    http://thedu.us/scripts/ghostrepeater/ghostrepeater 
# </tt>                .    Last invoked: May 18, 2008, when duus was feeling chipper.
# -------------------------- 

