help-cfengine
[Top][All Lists]
Advanced

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

Re: Exec a script to determine further action based on return code.


From: Brandon Evans
Subject: Re: Exec a script to determine further action based on return code.
Date: Fri, 24 Jun 2005 15:21:03 -0700
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

Knut Auvor Grythe wrote:
On Thu, Jun 23, 2005 at 04:56:01PM -0700, Brandon Evans wrote:

Here is an example that may help

control:
#  This returns 1 if there is a /home partation, 0 if not
ret_home = ( ExecResult(/bin/sh -c "df -l | grep -E '^/dev' | awk '{print $NF}' | 
grep -c '^/home'"))

classes:
# Here I use strcmp to check if ret_home is a 1 or 0
#  if it is a 1, HomePart is defined
HomePart = ( Strcmp("1","${ret_home}") )


What's the advantage of doing this, as opposed to
classes:
  HomePart = ( ReturnsZero(/bin/sh -c "df -l | grep '^/dev' | awk '{print $NF}' | 
grep -q '^/home$'") )

As far as I can see, that should do the same with less code. Plus, by
adding '$' to the end of the regex in the last grep, you avoid a false
positive on stuff like /home/a and /home/b (large sites often have to
split /home on multiple disks).


Your setup does make more sense. I just went with the first code that worked. Time to try out ReturnsZero()...




--
Thanks,
    Brandon Evans




reply via email to

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