Cfengine根据variables值执行操作

在cfengine中,我有一个variables被设置为一个命令的输出。 假设variablesmyoutput被设置为“hi world”。 我如何根据myoutput的内容执行命令。

我想要做这样的事情(sudo cfengine代码):

bundle agent test { vars: "myoutput" string => execresult("echo 'hi world';","noshell"); commands: myoutput=="hi world":: "/usr/bin/php myaction.php"; } 

有一个strcmp()函数: https : //cfengine.com/archive/manuals/cf3-Reference#Function-strcmp

尝试这个:

 bundle agent test { vars: "expected" string => "hi world"; "myoutput" string => execresult("/bin/echo 'hi world'","noshell"); classes: "equal" expression => strcmp($(myoutput),$(expected)); reports: equal:: "output is AS expected: $(myoutput)"; # do other stuff } 

如果execresult()的输出与预期的输出相同,则设置类“相等”。