[EMAIL PROTECTED] wrote:
hello
sorry to rehash an issue, but i'm still not able to get this to work in
spite of trying things suggested in previous threads. i've read these
threads:
'Problems with ExecResult & ReturnsZero in 2.1.18'
http://marc2.theaimsgroup.com/?t=113582729300001&r=1&w=2
'ReturnsZero and redirecting output'
http://cfengine.org/pipermail/help-cfengine/2006-March/000041.html
we have some (embarassingly old) versions of Mandrake in our
environment, and in cfengine 2.1.13, we use ReturnsZero to determine
which Mandrake version a host is.
groups:
mandrake9 = ( ReturnsZero(/bin/grep "Mandrake Linux release 9.0"
/etc/mandrake-release) )
mandrake91 = ( ReturnsZero(/bin/grep "Mandrake Linux release 9.1"
/etc/mandrake-release) )
mandrake10 = ( ReturnsZero(/bin/grep "Mandrake Linux release 10.0"
/etc/mandrake-release) )
while testing 2.1.20, the above isn't working, spewing stuff to STDOUT.
testing even failed when using grep -q. the upshot of the failure is
that the correct class isn't getting set, as i can see all 3 of the
above "mandrake*" show up in AddClassToHeap. i'll not yet paste
debugging output, unless requested.
i tested the above using various things, including putting quotes in
different places, escaping the quotes, etc. i'll paste them at the very
end.
another suggestion i read in one of the threads was to create a "module"
for this test. i'm not sure what is meant by that, i'll have to do more
reading of docs.
i could create a wrapper script to determine Mandrake version, and
return the exit status, but i was really hoping i could stick with using
grep. i suppose i could do something like this, and i hopefully write
*one* script correctly to do the right thing.
mandrake9 = ( ReturnsZero(/bin/sh -c '/tmp/am_i_mdk9.sh'))
mandrake91 = ( ReturnsZero(/bin/sh -c '/tmp/am_i_mdk91.sh'))
mandrake10 = ( ReturnsZero(/bin/sh -c '/tmp/am_i_mdk10.sh'))
last question: is this bit of documentation still correct wrt
ReturnsZero syntax? i tried exactly this syntax, and no workie.
http://www.cfengine.org/confdir/define-class-if-string-in-file.html
these are some variations i tried. certainly not exhaustive. if helpful,
i can add portions of -d2 output from the client.
mandrake9 = ( ReturnsZero(/bin/sh -c '/bin/grep "Mandrake Linux release
9.0" /etc/mandrake-release') )
mandrake9 = ( ReturnsZero('/bin/grep -q "Mandrake Linux release 9.0"
/etc/mandrake-release') )
mandrake9 = ( ReturnsZero(/bin/grep -q "Mandrake Linux release 9.0"
/etc/mandrake-release > /dev/null 2>&1) )
mandrake9 = ( ReturnsZero('/bin/grep -q \"Mandrake Linux release 9.0\"
/etc/mandrake-release') )
thanks much,
kallen
Looks like you need to sort out your quoting. See changelog 2.1.17 for
a example
result = ( ExecResult("/bin/sh -c \"${pf_cc} -V | head -1 | cut -d
-f3\"") )
not
result = ( ExecResult(/bin/sh -c "${pf_cc} -V | head -1 | cut -d -f3") )
Or write a module/prepmodule (see docs)
--
Mark Burgess
Professor of Network and System Administration
Oslo University College
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272 Email: [EMAIL PROTECTED]
Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
http://cfengine.org/mailman/listinfo/help-cfengine