如何在cfengine3中使用命令的输出


8

我想列出目录内容并在其他地方使用结果:

bundle agent test
{

   commands:
      "ls /tmp/test/";

    reports:
    ubuntu::
       "print output here for example";  
# or add it to a variable which is how I really want to use it.
 }

Answers:



4

从3.3.0版开始,您可以改用lsdir()函数。

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

阅读更多:https : //cfengine.com/manuals/cf3-Reference#Function-lsdir


实际上,这对于ls用例来说更好,因为它利用了CFEngine的内部函数缓存,并且每次运行都不会多次调用外部命令。当然execresult()更一般。
通配符
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.