LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 07:57 AM   #1
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Rep: Reputation: 13
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, 08:04 AM   #2
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Original Poster
Rep: Reputation: 13
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, 08:12 AM   #3
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

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

Original Poster
Rep: Reputation: 13
Hi millgates,

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


Reply



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 06:23 PM
[SOLVED] Script question: Shell script in kde to log in on a server with ssh c4719929 Programming 18 01-31-2011 09: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 03:05 AM
Question on this script. Echo Kilo Programming 2 12-13-2004 04:20 AM
some script-question G.P.P. Linux - Newbie 3 01-11-2003 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:34 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
Open Source Consulting | Domain Registration