Hi,

I'm trying to call execresult with a command which can produce slightly 
different output each time. In the process I realized that it seems to 
be called multiple times. Is this behavior by design?

Is there some way I can evaluate a command -once- and retain the output 
in a variable?

(see below for a simple promises.cf, with sample output).

Thanks,

Ian

rm -f /tmp/execresultlog; cat /tmp/promises.cf; cf-agent -I -K -f
/tmp/promises.cf; cat /tmp/execresultlog


body common control
{
bundlesequence =>
{
"test"
};
}

bundle agent test()
{
vars:
"test"
string => execresult("/bin/date +%N|tee -a /tmp/execresultlog", "useshell");
reports:
!jkjkjkfre::
"$(arg) $(test)";
}
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 13
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 18
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 13
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 18
R: $(arg) 920662078
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 18
!! Duplicate selection of value for variable "test" in scope test
!! Rule from /tmp/promises.cf at/before line 18
823584910
832880731
844173912
855688053
868540314
879644352
892530068
905851259
920662078
936708433
952164586
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to