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: Knut Auvor Grythe
Subject: Re: Exec a script to determine further action based on return code.
Date: Fri, 24 Jun 2005 09:23:27 +0200
User-agent: Mutt/1.5.6i

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 this:

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).

-- 
Knut Auvor Grythe
ITEA Systemdrift




reply via email to

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