How can I use the output of a command in cfengine3

bundle agent test
{

    vars:
        "my_result" string => execresult("/bin/ls /tmp/test/","noshell");

    reports:
        ubuntu::
            "Output is : $(my_result)";  
}

See https://cfengine.com/manuals/cf3-solutions#Execresult-example


As of version 3.3.0, you can use the lsdir() function instead.

vars:
  "result" slist => lsdir("/tmp/test", ".*", "false");

read more : https://cfengine.com/manuals/cf3-Reference#Function-lsdir