Felix, On Dec 13, 2010, at 5:52 PM, Felix Frank wrote:
> > Am I right to assume that > test -f /does_not_exist *always* returns 1 and > test -d / *always* returns 0? Yes. I should be more clear, because I need an \not\exists operator. If one or more conditions fail I want to run the command. Below I have a written a solution using "unless" with "&&". > If so, I don't see the problem ;/ > Either both pass (onlyif) or both fail (unless). > Use "test -f /does_not_exist || test -d /" to accept either one passing. That works, but it is not what I am searching for. Have a look here: # does not run if both conditions fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", onlyif => [ "test -f /does_not_exist || test -d /no"]}' # does run if one condition fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", onlyif => [ "test -f /does_not_exist || test -d /"]}' notice: /Stage[main]//Exec[run_rsn]/returns: executed successfully Otherwise there is unless, but it did not work as I need, too. # does not run if one condition fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", unless => [ "test -f /does_not_exist || test -d /"]}' # does run if both conditions fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", unless => [ "test -f /does_not_exist || test -d /foo"]}' notice: /Stage[main]//Exec[run_rsn]/returns: executed successfully A solution is &&, but I don't think that it is "nice" to use if there are onlyif and unless. # does run if one condition fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", unless => [ "test -f /does_not_exist && test -d /"]}' notice: /Stage[main]//Exec[run_rsn]/returns: executed successfully # does run if both conditions fail $ puppet -e ' Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" } exec { "run_rsn": command => "touch /bar", unless => [ "test -f /does_not_exist && test -d /foo"]}' notice: /Stage[main]//Exec[run_rsn]/returns: executed successfully Thanks anyway all the best, Sandor Szücs -- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.