LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-15-2010, 03:29 AM   #1
ajiteshsagar
LQ Newbie
 
Registered: May 2010
Location: New Delhi, India
Posts: 1

Rep: Reputation: 0
Question 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.........

Last edited by ajiteshsagar; 05-17-2010 at 06:27 AM.
 
Old 05-15-2010, 01:24 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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.
 
  


Reply

Tags
cronjobs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
in.tftp pxelinux.0_ fails with TFTP open timeout deadeyes Linux - Server 1 05-28-2010 10:07 AM
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
after re-create tftp dir, tftp doesn't work anymore lastguy Linux - Networking 2 11-16-2007 03:33 PM
tftp issue, unable to transfer kernel image using tftp to boot ltsp-client noobs4linux Linux - Networking 1 02-07-2007 01:53 AM
TFTP-Problem: TFTP timed out Bikerpete Linux - General 2 08-14-2003 05:25 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration