|Subject:||Re: Odd ReturnsZero function problem -- Re: defining classes based on returning results of (shell) commands?|
|Date:||Fri, 25 Aug 2006 10:01:28 -0700|
Thanks for example. But which version of cfengine are
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
mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*'
> /dev/null 2>&1") )
localBoot = ( ReturnsZero(/bin/sh -c
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.
--- "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:
> "WARNING: System is mounting /opt/local from
> the wrong filer"
> On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote:
> > Hi,
> > If there are any ways to define groups/classes
> > the return results of (shell) commands? Currently
> > there is a function called ReturnZero can be used
> > define classes based on exit code, like explained
> > the online reference:
> > ReturnsZero(command)
> > True if the named shell command returns with exit
> > 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
> > 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
> ~~ ** ~~ 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
Help-cfengine mailing list
|[Prev in Thread]||Current Thread||[Next in Thread]|