Forum: Cfengine Help
Subject: Re: Array member
Author: Igor
Link to topic: https://cfengine.com/forum/read.php?3,19475,19531#msg-19531
It would be nice to do slist based on an array... :(
https://cfengine.com/forum/read.php?3,13991,18938#msg-18938
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
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.c