help-cfengine
[Top][All Lists]
Advanced

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

Re: ForEachLineIn/ReadArray ??


From: Tim Nelson
Subject: Re: ForEachLineIn/ReadArray ??
Date: Mon, 31 Jan 2005 11:47:04 +1100 (EST)

On Fri, 28 Jan 2005, Andy Mace wrote:

Ok.. I basically have a file with strings on each line
I want to loop around the file and read each string on the line and write a line out in a config file.

Ah. This is one that I personally would solve with Perl (or rather, the perl templating solution that I use), and then run that using cfengine's "shellcommands". AFAIK, cfengine editfiles doesn't have a facility for putting a line into a variable (or rather, only into the currentline variable, which acts like Perl's $_ variable), and neither do I know of any way to write to a non-current file using editfiles. Hmm. Mark, we might want to consider solving these problems when we redesign editfiles in the future. I'll try and remember to add a link to this thread to the wiki once these posts appear in the archive.

If you really wanted to solve it with cfengine, the only way I can think of is:
1.      Use a "copy" stanza to copy the base file to a temp file
2.      Use editfiles to transform the temp file into exactly what you
        want in the config file
3.      Use a shellcommands "mv" to copy the new config file over the old
        one.

        There may be other solutions, but I'm unaware of them.

        :)

--
Tim Nelson
Server Administrator
WebAlive Technologies Global
Level 1 Innovation Building, Digital Harbour
1010 LaTrobe Street
Docklands, Melbourne, Vic, 3008
Phone: +61 3 9934 0812
Fax: +61 3 9934 0899
E-mail: address@hidden
http://www.webalive.biz/

"Your Business, Your Web, Your Control"




reply via email to

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