help-cfengine
[Top][All Lists]
Advanced

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

Odd ReturnsZero function problem -- Re: defining classes based on return


From: Robinson Tiemuqinke
Subject: Odd ReturnsZero function problem -- Re: defining classes based on returning results of (shell) commands?
Date: Fri, 25 Aug 2006 01:18:45 -0700 (PDT)

Hi, 

 Thanks for example. But which version of cfengine are
you running? 

 I'm using cfengine 2.1.18 and the ReturnsZero
function always thinks that the included commands
returns zero (success)!! -- pretty Odd and Funny!

 See my example:
...
  netBoot = ( ReturnsZero(/bin/sh -c
"PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
    mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*'
> /dev/null 2>&1") )
  localBoot = ( ReturnsZero(/bin/sh -c
"PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
    mount | egrep '^/dev/[sh]da.*?[ \t]+on[ \t]*/[
\t]*' > /dev/null 2>&1") )
...

 Only one shoud be true, either from ramdisk
(/dev/ram?) or local disk (/dev/[sh]da) my machines
will find its root file system. But see what? cfengine
sets both netBoot and localBoot classes at the same
time on any machines!

 from command line we can see that one command returns
exit code 0, anther one returns 1 if we run the above
encolsed commands manually.

 Please help.



 

--- "David E. Nelson" <address@hidden> wrote:

> 
> Hi Robinson,
> 
> How about leveraging 'egrep'?  For example, I use
> something like the following 
> in my 'groups:' section:
> 
> WrongOptLocal = ( ReturnsZero(/bin/sh -c
> "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; 
> mount | egrep 'filer:/vol/vol0/opt/local' >
> /dev/null 2>&1") )
> 
> Use regex w/ egrep to get as specific as you want.
> 
> And then in 'alerts:' I have:
> 
> alerts:
> 
>    WrongOptLocal::
> 
>      "WARNING: System is mounting /opt/local from
> the wrong filer"
> 
> Regards,
>        /\/elson
> 
> 
> On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote:
> 
> > Hi,
> >
> > If there are any ways to define groups/classes
> with
> > the return results of (shell) commands? Currently
> > there is a function called ReturnZero can be used
> to
> > define classes based on exit code, like explained
> in
> > the online reference:
> >
> > ReturnsZero(command)
> > True if the named shell command returns with exit
> code
> > zero (success).
> >
> > But what I’d like to have is something like the
> > following:
> >
> > strCmpReturn(identificationString, command)
> >
> >     True if the named shell command returns with
> > (exactly) the identificationString(or number).
> >
> > If there is already a function like the above? If
> > not, anyone can suggest another way to workaround
> it?
> >
> > Thanks a lot.
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
> > _______________________________________________
> > Help-cfengine mailing list
> > address@hidden
> >
> http://lists.gnu.org/mailman/listinfo/help-cfengine
> >
> 
> -- 
> ~~ ** ~~ Research has shown that Mondays account for
> 1/7th of your time ~~ ** ~~


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

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