Andrew,

String list is not treated as an indexed array, i.e. you cannot access
a single element in slist. Arrays are defined as follows:

vars:
   "array_name[foo]" string => "foo";
   "array_name[bar]" string => "blank";

the list of indexes can be then obtained by

    "aidx" slist => getindices("array_name");

2010/11/29 Andrew V. Stepanov <st...@altlinux.org>:
> Hello.
> How to access to array element?
>
> [r...@mn inputs]# cat test5.cf
>
> body common control
> {
> bundlesequence  => { "main" };
> }
>
> bundle agent main {
> vars:
>  "array" slist => {"firts", "second"};
>
>
> commands:
>  "/bin/echo $(array)";
>  "/bin/echo $(array[0])";
> }
>
>
>
>
>
>
> [r...@mn inputs]# cf-agent -f test5.cf  -K
> Q: ".../bin/echo firts": firts
> I: Last 1 QUOTed lines were generated by promiser "/bin/echo firts"
> Q: ".../bin/echo secon": second
> I: Last 1 QUOTed lines were generated by promiser "/bin/echo second"
> Q: ".../bin/echo $(arr": $(array[0])
> I: Last 1 QUOTed lines were generated by promiser "/bin/echo $(array[0])"
>
>
>
> It alwas pritns $(array[0]).
>
> Please help.
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>



-- 
SY, Seva Gluschenko.
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to