Try this, it's more native to CFEngine, though I still use an external command to report the detected file.
# Report all files in directory /tmp/. matching regex pattern \w.* bundle agent example { files: "/tmp/." file_select => files_we_care_about, transformer => "/bin/echo DETECTED $(this.promiser)", depth_search => recurse("inf"); } ############################################ body file_select files_we_care_about { leaf_name => { "\w.*" }; # leaf_name = regex to match against file name file_result => "leaf_name"; } ############################################ body depth_search recurse(d) { depth => "$(d)"; } Yours, Aleksey On Sun, Aug 26, 2012 at 12:37 AM, Abid Khwaja <a...@tyrann.net> wrote: > That would do exactly what I want but it seems fileexists() wants to see > only a fully qualified file name - regex’s don’t work. I need to use a > regex because the only information I have is that a file in the directory > will match \w.* > > > On Aug 26, 2012, at 8:36 AM, Aleksey Tsalolikhin wrote: > > Classes: "somefilesthere" > Expression => fileexists(...); > > Reports: > Somefilesthere:: > "Report text"; > > How's that? > > On Aug 25, 2012 10:33 PM, "Aleksey Tsalolikhin" <atsaloli.t...@gmail.com> > wrote: >> >> Hi Abid. Check out the fileexists() function. You can use it to set a >> class which you can link to a reports promise. >> >> Yours, >> Aleksey >> >> On Aug 25, 2012 9:03 AM, "Abid Khwaja" <a...@tyrann.net> wrote: >>> >>> I’m running community 3.2.3. >>> >>> My goal is to notify a group of non-technical users whenever there are >>> files in a particular directory - the normal state is that the directory >>> should be empty. I’m currently doing this via the following: >>> >>> bundle agent main >>> { >>> files: >>> “/apps/myApp_files/errors/time/.*" >>> file_select => plain, >>> delete => tidy, >>> action => warn_only; >>> } >>> >>> I’m using “delete => tidy” only because I need something to attach the >>> “action” attribute to - I never actually want to ever delete or touch any of >>> the files in the directory. Is this the smartest way to achieve what I >>> want? >>> >>> Also, while the above works, it’s not optimal because you get a lot of >>> text in the warn message that non-technical users don’t understand. A >>> better way would be to define a class if any files are found in the >>> directory and use that class in a reports section to send out a more easier >>> to understand message. How would I define such a class? >>> _______________________________________________ >>> Help-cfengine mailing list >>> Help-cfengine@cfengine.org >>> https://cfengine.org/mailman/listinfo/help-cfengine > > -- Upcoming Trainings: "Editing with vi" 31 Aug 2012 at LinuxCon North America in San Diego, CA (http://lcna2012.sched.org/speaker/alekseytsalolikhin) "Time Management for System Administrators" 28 Sep 2012 at Ohio Linux Fest (http://ohiolinux.org/register) "Editing with vi" 28 Sep 2012 at Ohio Linux Fest (http://ohiolinux.org/register) "Automating System Administration with CFEngine 3" 22-25 Oct 2012 in Palo Alto, CA (http://www.eventbrite.com/event/3388161081) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine