help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: ReturnsZero(): command does not return zero. Is class created with v


From: Wheeler, John
Subject: RE: ReturnsZero(): command does not return zero. Is class created with value of false?
Date: Wed, 1 Oct 2003 09:24:22 -0500

I use this to check for a user:

tomcatuserexists = ( ReturnsZero(/usr/xpg4/bin/grep -q tomcat /etc/passw
d ) )

its kind of a hack, I need to look at getent instead of the grep
command.

One thing I learned from "ReturnsZero" is that if your shell command
generates output to std out, this can potentially cause an email to be
issued. This behavior changed after ~ 2.0.6 such that email is only
generated if the cfagent output changes between runs. This is why I use
the more obscure grep (/usr/xpg4/bin/grep) on solaris, no output just a
return value indicating found or not.

-----Original Message-----
From: Mark.Burgess@iu.hio.no [mailto:Mark.Burgess@iu.hio.no] 
Sent: Tuesday, September 30, 2003 11:25 PM
To: hans@deragon.biz
Cc: help-cfengine@gnu.org
Subject: Re: ReturnsZero(): command does not return zero. Is class
created with value of false?


I'm sorry -- I didn't read this properly first time
around. the problem is a misunderstanding of the ReturnZero()
function. It is the value of the shell returncode that is tested
not the value of the text string printed by the command.
You will need to use StrCmp("0",$returnvar) if you want to test that.
Since fgrep will always succeed if /etc/passwd exists, it will always
return zero in the sense of ReturnZero().

I believe it is explained in the manual that classes are attributes
that are either defined or not. It is certainly implicit in all
of the docs, but whether or not it is clear is of course a matter
of opinion! :)

Mark

On 30 Sep, Hans Deragon wrote:
> Mark.Burgess@iu.hio.no wrote:
>> !class is true if class does not exist. Your problem might be
>> related to a bug that some have reported in evaluating 
>> classes with the string ".!class". Try swapping the order
>> of the classes and see if it makes a difference
>> 
>> M
> 
> Nothing different.  Can you reproduce the problem on your side?  My
example is 
> pretty trivial...  I am running 2.1.0b2.
> 
> BTW, you dodged my other question. ;)  Is it documented somewhere that
a class 
> is either defined or not and that !class is true if the class is
undefined?  If 
> not, it should. :)
> 
> ----->
> Appending [lmclxadm](BuildClassEnvironment)
> ---
> ENVIRONMENT: 
>
CFALLCLASSES=any:cfengine_2_1_0b2:redhat:redhat_9:opt_debug:Tuesday:Hr14
:Min48:Min45_50:Q4:Hr14_Q4:Day30:September:Yr2003:linux:snah1:32_bit:lin
ux_2_4_20_6:i686:linux_i686:linux_i686_2_4_20_6:linux_i686_2_4_20_6__1_T
hu_Feb_27_10_06_59_EST_2003:compiled_on_linux_gnu:localhost:net_iface_lo
:net_iface_eth0:142_133_112_30:snah1_dyn_lmc_ericsson_se:142_133_112:ipv
4_142_133_112_30:ipv4_142_133_112:ipv4_142_133:ipv4_142:lmclxadm:
> ---
> 
>                    New temporary class additions
>                    --------( Pass 1 )-------
>                               lmclxadm
> Actionsequence item shellcommands
> Job start time set to Tue Sep 30 14:48:18 2003
> 
> ---------------------------------------------------------------------
> Alerts
> ---------------------------------------------------------------------
> 
> 
> 
> ++++++++++++++++++++++++++++++++++++++++
> Summary of objects involved
> ++++++++++++++++++++++++++++++++++++++++
> 
>      global
>      main
> <-----
> 
> Best regards,
> Hans Deragon
> --
> Consultant en informatique/Software Consultant
> Deragon Informatique inc.         Open source:
> http://www.deragon.biz            http://swtmvcwrapper.sourceforge.net
> mailto://hans@deragon.biz         http://autopoweroff.sourceforge.net
> 
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://mail.gnu.org/mailman/listinfo/help-cfengine





reply via email to

[Prev in Thread] Current Thread [Next in Thread]