web-dev-qa-db-ja.com

cfengine3でコマンドの出力を使用するにはどうすればよいですか

ディレクトリの内容を一覧表示し、その結果を別の場所で使用したいと思います。

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.
 }
8
awsiv
bundle agent test
{

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

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

https://cfengine.com/manuals/cf3-solutions#Execresult-example を参照してください

12
faker

バージョン3.3.0以降では、代わりにlsdir()関数を使用できます。

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

続きを読む: https://cfengine.com/manuals/cf3-Reference#Function-lsdir

4
Pledge