Not certain how this fixed it but this is the issue I had with it.

[EMAIL PROTECTED] root]# cat cf.awk
control:

    actionsequence = ( shellcommands )

shellcommands:

    "/bin/echo 'test test2' | /bin/awk '{ print $2 }'"
[EMAIL PROTECTED] root]# cfagent -f ./cf.awk -IK
cf:cfengine::./cf.awk:8: Incomplete variable syntax or bracket mismatch
[EMAIL PROTECTED] root]# vi cf.awk
[EMAIL PROTECTED] root]# cat cf.awk
control:

    actionsequence = ( shellcommands )

shellcommands:

    "/bin/echo 'test test2' | /bin/awk '{ print ${dollar}2 }'"
[EMAIL PROTECTED] root]# cfagent -f ./cf.awk -IK
cfengine:: Executing script /bin/echo 'test test2' | /bin/awk '{ print
$2 }'...(timeout=0,uid=-1,gid=-1)
cfengine::/bin/echo 'test: test2
cfengine:: Finished script /bin/echo 'test test2' | /bin/awk '{ print $2 }'
[EMAIL PROTECTED] root]#


Notice I changed $2 -> ${dollar}2

On 2/10/06, Josh Hurd <[EMAIL PROTECTED]> wrote:
>
> I was able to solve this problem with the following:
> control:
>         openBrace = ( "{" )
>         closeBrace = ( "}" )
> shellcommand:
>         "/bin/ps axo \"stime,pid,command\" | /bin/awk ' ${openBrace} print
> $2 ; ${closeBrace} ' "
>
> not sure if this is the most graceful method but it works!
>
> Josh
>
>  ________________________________
>  From: Josh Hurd
> Sent: Friday, February 10, 2006 1:30 PM
> To: [email protected]
> Subject: Escape {} in shellcommnads?
>
>
>
>
> I am trying to run a shellcommand that includes a call to awk.  Awk requires
> the use of braces but CFE treats tham as variable substitutuions.  I have
> tried escaping them with \ with no success.  I've tried using single quotes
> and double quotes.
>
> Here is a sample:
> "/bin/ps axo \"stime,pid,command\" |  /bin/awk ' {print $2 ;} ' "
>
> The error returned is:
> Incomplete variable syntax or bracket mismatch
>
> Does anyone know how to pull this off?  I don't want to deploy a one line
> shell script to all my clients.
>
> Thanks!
> Josh
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-cfengine
>
>
>


--
Christian Pearce


_______________________________________________
Help-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-cfengine

Reply via email to