OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
sh script from cron

From: Roy Morris (rmorrisinternetsecure.com)
Date: Wed Dec 01 2004 - 13:15:13 CST


I have a neat error. I wrote a small script (see below) that checks my
website. if I run the script manually it works fine. but if I run it from
roots cron, it does not work as expected. The first part about default if we
can't reach the site fails. Any ideas? Try running this and you will
see!!

Here is my cron entry.
*/1 * * * * /bin/sh /home/rmorris/fh.sh

Here is what I get in my log, if I run it from the console.
# /bin/sh fh.sh
# tail /tmp/sysmon.log
Wed Dec 1 14:09:39 EST 2004 - Checking www.finalhour.ca, the return value was
200

when I run from cron I get this.
Wed Dec 1 14:11:01 EST 2004 - Checking www.finalhour.ca, the return value
was
** CRITICAL ** No Access to Finalhour.ca

Am I nuts? or am I missing something very simple here!

#### Script #####
# Address's to send to
ops1="rmorrisfinalhour.ca"

# Request Site Status ##
AdminStatus=`curl -k -s -I http://www.finalhour.ca |grep "HTTP/1.1" |awk
'/HTTP/ {print $2}'`

### Do some logging, for debug ###
echo "$(date) - Checking www.finalhour.ca, the return value was
${AdminStatus}" >>/tmp/sysmon.log

# Default if we can't reach the site
if [[ -z ${AdminStatus} ]]; then
        echo "** CRITICAL ** No Access to Finalhour.ca\n\nThe system monitor
tool was not able to reach the site,\n\nPlease check this." >>/tmp/sysmon.log
        exit
fi

## We got to the site, but the code is wrong
if [ ${AdminStatus} -ne 200 ]; then
        echo "System Monitor encountered the following error : 05 (DNS) \n \n
\n Over the last 30 minutes, System Monitor could not access Finalhour (using
DN
S)\n \n \n System Monitor (Royshouse) V1.0" >>/tmp/sysmon.log
fi

Roy Morris
Operations
Internetsecure Inc
905.469.6522 X291
-------------------------
D9D5AE802DC2B7A1