Forum: CFEngine Help Subject: help with commands - append date to file Author: matt_garman Link to topic: https://cfengine.com/forum/read.php?3,23912,23912#msg-23912
Hi, I'm just getting started with CFEngine3. I'm using the cfengine-community package v3.2.1-1.el5 on CentOS 5.7. I'm starting with the Make sure /tmp/test_plain exists example. Used as-is, it works. Next step: modify it to (1) run automatically via cf-agent, and (2) append the output of the "date" command to the file every time it runs. This is what I have: bundle agent test1 { vars: "testfile" string => "/tmp/test_plain"; files: "${testfile}" -> "Some Person", comment => "Make sure ${testfile} exists", create => "true"; commands: "/bin/date >> ${testfile}" comment => "Echo current date to our file"; } This lives in a file named "test1.cf", which is included via the "inputs" section of my promises.cf file. I also specify "test1" as part of my bundlesequence in promises.cf. I waited five minutes, constantly tailing the file, yet I never saw the date appended. So if I try to run it explicitly via "cf-agent -f promises.cf", the output is this: R: --> CFE is running on Q: ".../bin/date >> /t": /bin/date: extra operand `/tmp/test_plain' Q: ".../bin/date >> /t": Try `/bin/date --help' for more information. I: Last 2 quoted lines were generated by promiser "/bin/date >> /tmp/test_plain" Here is a snippet from the same command with the -I and -v options: cf3> ========================================================= cf3> commands in bundle test1 (1) cf3> ========================================================= cf3> cf3> -> Promiser string contains a valid executable (/bin/date) - ok cf3> cf3> ......................................................... cf3> Promise handle: cf3> Promise made by: /bin/date >> /tmp/test_plain cf3> cf3> Comment: Echo current date to our file cf3> ......................................................... cf3> cf3> -> Executing '/bin/date >> /tmp/test_plain' ...(timeout=-678,owner=-1,group=-1) cf3> -> (Setting umask to 77) cf3> !! Finished command related to promiser "/bin/date >> /tmp/test_plain" -- an error occurred (returned 1) cf3> Q: ".../bin/date >> /t": /bin/date: extra operand `/tmp/test_plain' Q: ".../bin/date >> /t": Try `/bin/date --help' for more information. cf3> I: Last 2 quoted lines were generated by promiser "/bin/date >> /tmp/test_plain" cf3> -> Completed execution of /bin/date >> /tmp/test_plain cf3> Of course if I manually run "/bin/date >> /tmp/test_plain" it works as expected. So it seems CFEngine is doing something to my command. Thanks, Matt _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine