0

I have query about shell script

MYIPPADDR=`ifconfig ppp0 2>/dev/null|awk '/inet addr:/ {print $2}' | sed 's/addr://'`
if [ ! -z "$MYIPPADDR" -a "$MYIPPADDR" != "" ];

where MYIPPADDR, i am getting my pc ip address and i am checking condition that weather it is null or blank and the script file which i am using is executes properly in console but executes again and again by crontab. So could not able to trace it out where the problem is. Can some one help me on this.

1 Answer 1

1

cron runs in a very limited environment: the PATH is something very basic like /bin:/usr/bin

You need to provide the full path to ifconfig: /usr/sbin/ifconfig (probably)


Note that [ ! -z "$var" ] and [ "$var" != "" ] test exactly the same thing.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi glenn jackman, At frist thanks for your reply and what you suggested is worked. i should give proper path of ifconfig. is there any way that we can put some log in shell script which will executed by crontab and we can trace where the problem is. thanks rabi
look in /var/log/syslog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.