help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding OR editing line only if not present


From: Florian Thiel
Subject: Re: Adding OR editing line only if not present
Date: Fri, 7 Feb 2003 08:21:37 +0100
User-agent: Mutt/1.4i

Jamie Wilkinson schrieb:
> Quoting Florian Thiel <noroute@web.de>:
> 
> > What I want to do is the following:
> > Append a certain line if it's not already there. If it's there, see if
> > it maches a certain regexp. If it doesn't, replace it.
> 
> This is the goal of my cf.ssh which I posted yesterday.  Your construct is a 
> bit
> shorter, as you're using AppendIfNoLineMatching, whereas I use a 
> Begin/EndGroup.
> 
> > LocateLineMatching "^allow="
> > BeginGroupIfNoMatch "^allow=10\.\$(nr)\.0\.0/255\.255\.0\.0 127\.0\.0\.1"
> >   ReplaceLineWith "allow=10\.$(nr)\.0\.0/255\.255\.0\.0 127\.0\.0\.1"
> > EndGroup
> > DefineClasses "restart_webmin"
> 
> This is the only way you can do it.  But I'd like to point out that the
> ReplaceLineWith takes a quoted-string, not a regex, so you don't need to 
> escape
> the fullstops.  I'd also not bother with the BeginGroupIfNoMatch line.

If I do not use BeginGroupIfNoMatch the line will be changed every time
the script runs, doesn't it? But that is exactly the point!

Florian
-- 
Florian Thiel - Medienzentrum Kassel
Systembetreuung Internet- und Kommunikationstechnik
Kasseler Schulen am Netz - http://www.medienzentrum-kassel.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]