PDA

Bekijk de volledige versie : OpenDNS script



kauczu
30-09-2008, 15:30
Hi.

I have strange situation with OpenDNS update script.
It is looks like this:

#!/bin/sh
TEMP=pliktemp
trap cleanup 1 2 3 6
cleanup()
{
rm $TEMP
exit 1
}

update()
{
/opt/bin/curl -o $TEMP -u user:password https://updates.opendns.com/nic/update


if [ `cat $TEMP | grep -c good` = 1 ]
then
logger OpenDNS updated successfully
else
while [ $ERROR -gt 0 ]; do
ERROR=$(($ERROR-1))
sleep 10s
update
done
logger OpenDNS update failed
fi
}

update
rm $TEMP
exit 0

When I run this script manually it is working fine, in system log I got something like:

Sep 30 16:11:46 admin: OpenDNS updated successfully
But when I put this script in cron "cron.hourly" directory, after execution in system log i got:

Sep 30 16:01:33 admin: OpenDNS update failed
What is wrong?

Please give some help :)

al37919
30-09-2008, 17:29
Generally speaking, the probable difference between manual run of the script and starting of it from cron (or post-boot etc.) is the environment. Usually in such cases there is something wrong with PATH variable.

I'd suggest:
1) check what the environment is during the execution of the script
2) declare PATH explicitly at the beginning of the file