help-cfengine
[Top][All Lists]
Advanced

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

Re: non-convergent file edit?


From: Tim Nelson
Subject: Re: non-convergent file edit?
Date: Wed, 17 Mar 2004 12:07:16 +1100 (EST)

On Tue, 16 Mar 2004 rader@ginseng.hep.wisc.edu wrote:

>  > How does cfengine know between invocations that
>  > "last time" we did it, so "this time" we mustn't?
>
> "Last time" vs "this time" isn't an issue if you trigger ReplaceOnce
> with a define= class.  Or, think of it this way: "every time".
> Doesn't ReplaceAll behave the same way?

        This is extra information (the define class) which enables us to
answer you.  If you use a BeginGroupIfDefined, you should be able to do
what you want, I think.  Then again, I'm a cfengine novice too :).  So,
plagiarising liberally from Chris' earlier post:

BeginGroupIfDefined "IWantToDoThis"
        ReplaceAll "[[:digit:]]{2}[[:alpha:]]{3}[[:digit:]]{2}" With 
"$(day)$(month)$(year)"
EndGroup

        Of course, if you're munging your cfengine inputs with
Text::Template, you do:

-----------------
sub     ReplaceAllIfDefined {
        my($class, $regex, $replacement) = @_;
        return <<EOT
                BeginGroupIfDefined "$class"
                        ReplaceAll "$regex" With "$replacement"
                EndGroup
EOT
}
-----------------

        ...and then just call ReplaceAllIfDefined.

        :)

--
Tim Nelson
Systems Administrator
Sunet Internet
Tel: +61 3 5241 1155
Fax: +61 3 5241 6187
Web: http://www.sunet.com.au/
Email: sysadmin@sunet.com.au







reply via email to

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