control: any:: file_content = ( ExecResult(/bin/grep ${host} ${inputfile}) ) editfiles: any:: { ${output_file} AutoCreate EmptyEntireFilePlease AppendIfNoSuchLine "${file_content}" }
This works when you only need to extract one line from the inputfile, but it should not be that hard to modify it to support multiple lines. On Fri, Dec 11, 2009 at 3:32 AM, Tom Van de Velde <tom_vandeve...@yahoo.com> wrote: > Hi, > > Sorry for my sloppy explanation indeed :-) > > I have 1 big input file containing lines starting with a host name. > On every host I want to create a separate file from this input file, but it > only contains the lines that need to be present on that host. somthing like > grep $hostname inputfile.txt > outputfile.txt > > Regards, > Tom > > > --- On Fri, 12/11/09, Brendan Strejcek <strej...@gmail.com> wrote: > >> From: Brendan Strejcek <strej...@gmail.com> >> Subject: Re: question on file creation (V2) >> To: "Tom Van de Velde" <tom_vandeve...@yahoo.com> >> Cc: help-cfengine@cfengine.org >> Date: Friday, December 11, 2009, 4:55 AM >> Can you try to restate the problem? I >> don't see exactly what you are >> getting at. If you want to insert the hostname into a file, >> editfiles >> should be able to do that. >> >> On Wed, Dec 9, 2009 at 2:46 AM, Tom Van de Velde >> <tom_vandeve...@yahoo.com> >> wrote: >> > Hi, >> > >> > I'm facing a problem where i need to construct a file >> with content. (where is the problem here :-) ) >> > Well the content is based on the hostname ... >> > >> > So I have a input.txt with : >> > server1 command 1 option 1 >> > server1 command 2 option 4 >> > server1 command 3 option 4 >> > server2 command 1 option 4 >> > server2 command 5 option 4 >> > >> > in bash a simple grep should do the trick ... but how >> can cfengine handle this. >> > >> > One extra thing to know... it is cfengine version 2, >> that is still used.... >> > >> > Regards, >> > Tom >> > >> > >> > >> > _______________________________________________ >> > Help-cfengine mailing list >> > Help-cfengine@cfengine.org >> > https://cfengine.org/mailman/listinfo/help-cfengine >> > >> > > > > _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine