help-cfengine
[Top][All Lists]
Advanced

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

Re: Using nawk with cfengine


From: DRANSUTAVICIUS, CLAUDIO
Subject: Re: Using nawk with cfengine
Date: Fri, 18 Jun 2004 12:14:16 -0400

Hi Brendan

Thanks for re-affirming what I have discovered.

The reason I want to use uppercase is you do not know how a user has build
/etc/resolv.conf
Is it   cs.uchicago.edu
or
CS.uchicago.EDU
or combinations there of.

If you change it all to upper or lower then you can do tests like the
following:

groups:
West = ( Strcmp("CS.UCHICAGO.EDU","${domain}") )

shellcommands:

    West::
         "/usr/bin/echo - This is the Western Domain $(domain) "

On a side note: Once the class is set how can you define a variable or macro
depending on class

i.e.  West class is set I want to use this policyhost
       East class is set I want to use this policyhost

But only have one variable set for policyhost.

Thanks for any help.

T.J.




Brendan Strejcek wrote:

> The problem seems to be in how cfagent parses the parentheses.
>
> $ cat ExecResult.cf
> #!/usr/local/sbin/cfagent -qKf
> control: actionsequence = ( shellcommands )
> var = ( ExecResult(/usr/bin/awk '/search/ { print $2 }' /etc/resolv.conf) )
> shellcommands: "/bin/echo ${var}"
> $ ./ExecResult.cf
> cfengine::/bin/echo cs.uc: cs.uchicago.edu
> $
>
> If you don't really need it upper case, the above works. If you change
> that to { print toupper($2) }, cfagent pukes.
>
> Summary: don't use parentheses within ExecResult arguments.
>
> Example run on OpenBSD 3.5 with cfengine 2.1.6.






reply via email to

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