Forum: CFEngine Help Subject: Re: multidimensional array usage Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,23753,23761#msg-23761
I have to say I am stumped. I think this may be a bug. Any core developers who want to pitch in on this? Here's the standalone example: body common control { bundlesequence => { "parse_array" }; } bundle agent parse_array { vars: "dim" int => readstringarray("servers", "/tmp/multidim_data.txt","\s*#[^\n]*",":",100,10000); "hostnames" slist => getindices("servers"); "iparray[$(hostnames)]" string => "$(servers[$(hostnames)][1])"; "ips" slist => getvalues("iparray"); reports: cfengine:: "ips: $(ips)"; "iparray: $(iparray[$(hostnames)])"; } And here's what I'm using for /tmp/multidim_data.txt: host1:1.1.1.1:foo:bar:baz host2:2.2.2.2:boo:moo:zoo host3:3.3.3.3:bam:pam:nam And here's the output: $ cf-agent -KI -f ./multidimensional_array_usage.cf R: iparray: 1.1.1.1 R: iparray: 3.3.3.3 R: iparray: 2.2.2.2 So: - The "iparray" array is being correctly populated, as shown in the output (you can try other indices and verify the other values are there as well). - However, the "ips" list is left empty. I have tried looking at the debug output, but haven't been able to gather much from it. Any ideas? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine