[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Escape {} in shellcommnads?
From: |
christian pearce |
Subject: |
Re: Escape {} in shellcommnads? |
Date: |
Thu, 23 Feb 2006 14:55:13 -0500 |
Not certain how this fixed it but this is the issue I had with it.
[root@hsysnav01 root]# cat cf.awk
control:
actionsequence = ( shellcommands )
shellcommands:
"/bin/echo 'test test2' | /bin/awk '{ print $2 }'"
[root@hsysnav01 root]# cfagent -f ./cf.awk -IK
cf:cfengine::./cf.awk:8: Incomplete variable syntax or bracket mismatch
[root@hsysnav01 root]# vi cf.awk
[root@hsysnav01 root]# cat cf.awk
control:
actionsequence = ( shellcommands )
shellcommands:
"/bin/echo 'test test2' | /bin/awk '{ print ${dollar}2 }'"
[root@hsysnav01 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 }'
[root@hsysnav01 root]#
Notice I changed $2 -> ${dollar}2
On 2/10/06, Josh Hurd <JoshH@revenuescience.com> 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: help-cfengine@gnu.org
> 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
> Help-cfengine@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
>
>
>
--
Christian Pearce