디렉토리 내용을 나열하고 다른 곳에서 결과를 사용하고 싶습니다.
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.
}
답변
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을 참조 하십시오.
답변
버전 3.3.0부터 lsdir () 함수를 대신 사용할 수 있습니다.
vars:
"result" slist => lsdir("/tmp/test", ".*", "false");
더 읽기 :
https://cfengine.com/manuals/cf3-Reference#Function-lsdir