Using vars inside commands

8 views
Skip to first unread message

André Luís Lopes

unread,
Sep 11, 2012, 7:00:37 PM9/11/12
to help-c...@cfengine.org
Hello,

   I just wanted to double-check with you guys if using a var inside a command really doesn't work in CFEngine3.

   Example :

vars:
    "java_binary" string => execresult("/bin/ls -l /usr/java/*/bin/java | /usr/bin/awk '{print $9}' | /bin/sed ':a;N;$!ba;s/\n/,/g'", "useshell");
    "java_binary_list" slist => splitstring("$(java_binary_list)",",","20");

commands:
   "/sbin/paxctl -C $(java_binary_list)";

   The java_binary_list slist var is being populated with the content I want it to be populated with just fine.

   Additionally, I would like to be able to use it under the commands section. When running cf-agent manually in verbose mode, I can see that a string $(java_binary_list) is being passed to the to the /sbin/paxctl binary instead of each value of the java_binary_list var (using implicit loop).

cf3>  -> Executing '/sbin/paxctl -C $(java_binary_list)' ...(timeout=-678,owner=-1,group=-1)
cf3>  !! Finished command related to promiser "/sbin/paxctl -C $(java_binary_list)" -- an error occurred (returned 1)

   Is it true that a var can't really be used like this, inside a command in the commands section ?

--
André Luís Lopes
andr...@andrelop.org
http://andrelop.wordpress.com/
Public GPG KeyID : 9D1B82F6

Diego Zamboni

unread,
Sep 11, 2012, 10:32:44 PM9/11/12
to André Luís Lopes, help-c...@cfengine.org
That should work fine. Are you sure the list is being properly populated? 

--Diego
_______________________________________________
Help-cfengine mailing list
Help-c...@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

André Luís Lopes

unread,
Sep 12, 2012, 5:23:44 PM9/12/12
to help-c...@cfengine.org
Hello,

2012/9/12 Aleksey Tsalolikhin <atsalo...@gmail.com>
On Tue, Sep 11, 2012 at 7:32 PM, Diego Zamboni <di...@zzamboni.org> wrote:
> That should work fine. Are you sure the list is being properly populated?

Check with:

reports:
  cfengine_3::
      "$(java_binary_list)";


   It was way a result of way too little coffee on my blood. Wrong snippet :

"java_binary_list" slist => splitstring("$(java_binary_list)",",","20");

   Fixed snippet :

"java_binary_list" slist => splitstring("$(java_binary)",",","20");

   My bad. Fixed and now it's working. Thanks everyone :-)

Aleksey Tsalolikhin

unread,
Sep 12, 2012, 3:29:47 AM9/12/12
to help-c...@cfengine.org
On Tue, Sep 11, 2012 at 7:32 PM, Diego Zamboni <di...@zzamboni.org> wrote:
> That should work fine. Are you sure the list is being properly populated?

Reply all
Reply to author
Forward
0 new messages