LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   return value of tftp is always zero in cronjob (https://www.linuxquestions.org/questions/linux-newbie-8/return-value-of-tftp-is-always-zero-in-cronjob-807970/)

ajiteshsagar 05-15-2010 03:29 AM

return value of tftp is always zero in cronjob
 
I have called an script in cronjob named get_mac.sh as follows:

#!/bin/sh
MAC=`ifconfig eth0 |sed -n 1p|awk '{print $5}'|awk -F : '{print $1$2$3$4$5$6}'`
ARG_FILE="/etc/asterisk/scripts/server.params"
. ${ARG_FILE}
tftp -l $MAC.params -r $MAC.cfg -g $Server
if [ -s $MAC.params ]; then
echo "File downloaded successfully"
cat /etc/config/crontab|sed '/get_mac.sh/d'>crontab.bak
mv crontab.bak /etc/config/crontab
/etc/init.d/phone.sh > /etc/asterisk/scripts/phone.params
/etc/init.d/sip.sh > /etc/asterisk/sip.conf
/etc/init.d/users.sh > /etc/asterisk/users.conf
rm $MAC.params
/bin/reset_driver
else
echo "No or an empty file exists."
fi


But the problem is that the return value of tftp command is always zero and the if condition is always true. That's why i'm not getting the desired output.

Can anyone help me on this.

Thank You.........

theNbomr 05-15-2010 01:24 PM

It is quite possible, in fact likely, that your script does not run either ifconfig, or tftp, since you have not provided any $PATH with which to find it. Processes launched by cron do not have the same environment as those run from an interactive shell. The solution may be as simple as specifying the full path to the runtime binaries. If the script runs correctly from an interactive shell, then I would be even more certain that this is at least part of the problem.
--- rod.


All times are GMT -5. The time now is 12:00 AM.