LinuxQuestions.org
Register a domain and help support LQ
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
  Search this Thread
Old 02-06-2012, 08:57 AM   #1
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 60

Rep: Reputation: 8
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?
 
Old 02-06-2012, 09:04 AM   #2
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 60

Original Poster
Rep: Reputation: 8
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.
 
Old 02-06-2012, 09:12 AM   #3
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Hi,
does specifying the full path (such as /sbin/ip) in the script help?
 
1 members found this post helpful.
Old 02-06-2012, 09:32 AM   #4
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 60

Original Poster
Rep: Reputation: 8
Hi millgates,

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


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
script question rvaede Linux - General 2 03-06-2011 07:23 PM
[SOLVED] Script question: Shell script in kde to log in on a server with ssh c4719929 Programming 18 01-31-2011 10:26 AM
[SOLVED] Script question: create a shell script in kde to log in on a server with ssh c4719929 Linux - Newbie 1 01-31-2011 04:05 AM
Question on this script. Echo Kilo Programming 2 12-13-2004 05:20 AM
some script-question G.P.P. Linux - Newbie 3 01-11-2003 06:41 PM


All times are GMT -5. The time now is 06:25 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration