LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script question (https://www.linuxquestions.org/questions/linux-newbie-8/script-question-927890/)

KatrinAlec 02-06-2012 07:57 AM

script question
 
I want to delete a route in case it exists.
My script is:

if ip route | grep "80.0.0.0/8 dev ipsec0"
then
ip route del 80.0.0.0/8 dev ipsec0
logger -i -t myscript -- deleted
else
logger -i -t myscript -- not deleted
fi
exit 0

I'm running this every 10 minutes with a cronjob.
/bin/sh /tmp/myscript
Even if the route exists it tells me "not deleted".

If I run the script from the command line it deletes the route.

Any ideas why?

KatrinAlec 02-06-2012 08:04 AM

forgot to mention:
I'm getting an error message
ip: command not found

so I guess the line
if ip route | grep .... is the problem.

millgates 02-06-2012 08:12 AM

Hi,
does specifying the full path (such as /sbin/ip) in the script help?

KatrinAlec 02-06-2012 08:32 AM

Hi millgates,

it worked with the full path.
Thank you so much.


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