Forum: CFEngine Help
Subject: Re: filecopy, transform with grep.
Author: davidlee
Link to topic: https://cfengine.com/forum/read.php?3,22985,23012#msg-23012

Ben, Neil,

Thanks for your replies.

I should emphasise that I am doing this with the reference manual open in front 
of me at section 7.4.18, about "transformer", both in paper form at 3.1.4, and 
the online version (currently labelled "3.2.0b3.r2651:2652M").

I am looking particularly at the second example, about generating one postfix 
data file from another, using a command.

And that, in essence, is exactly what I want to do: generate one file from 
another.  The manual example uses "/usr/sbin/postalias"; my case would be a 
"/bin/grep -v".  But surely the parallelism still holds, doesn't it?

The only significant difference, for the purposes of this discussion, is that 
the given postfix example writes its output to a file (which I presume 
coincides with, but is not necessarily defined by, the cfengine promised file) 
and that my "grep" example writes to stdout.  Apart from that, the two cases 
are pretty much the same, aren't they?

Now I realise that my proposed suggestion omitted a "do_update" component.  I'm 
happy to re-instate that into my example, so please consider that re-inserted 
if you wish.

So my revised proposal, based closely on the postfix example in section 7.4.18 
would be modelled something like:
==========
classes:
"do_update" ...  ### note that section 7.4.18 is buggy here!!  But that's a 
side issue.

files:
"/path/to/resultfile"
create => true,
transformer => "/bin/grep -v $(fq.uqhost) /path/to/sourcefile"; # command 
outputs to STDOUT
transformer_stdout => "true", # capture STDOUT as potential new file
if varclass => "do_update";
==========
(BTW, my earlier example had accidentlly the "/path/to/sourcefile" argument; 
sorry.)

If the postfix example is acceptable, but my proposed parallel example with its 
proposed "transformer_stdout" extension is flawed, please could you explain the 
flaw?  Thanks.

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to