#!/bin/csh
# (modified by Gord-)  (modified again by ???)
#
# This is a script suitable for use in a crontab.  It checks your process
# list for an eggdrop bot.  If it doesn't find one, it will reload it.
# You'll need to edit this script for your bot.
#
# To check for your bot every 10 minutes, put the following line in your
# crontab:
#    0,10,20,30,40,50 * * * *   /home/mydir/botchk
#

# change this to the directory you run your bot from:
set botdir="/home/mydir/mybot"

# change this to the name of your bot's script in that directory:
set botscript="mybot"


set oldcwd=$cwd
cd $botdir
set botpid=`cat eggdrop.pid`
set chkbot=`ps x | grep '^ *$botpid'`
if "$chkbot" == "" then
  echo ""
  echo "Couldn't find the bot running.  Reloading it..."
  echo ""
  $botscript
  cd $oldcwd
  unset oldcwd
endif
unset chkbot
