Forum: CFEngine Help Subject: Getindices not working for me Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,26458,26458#msg-26458
policy: body common control { bundlesequence => { "main", }; inputs => { "cfengine_stdlib.cf", }; } bundle common g { vars: "mf_cache" string => "/var/cache/sitefiles"; "sitefiles" string => "${sys.workdir}/sitefiles"; } bundle agent main { methods: "simple service management" usebundle => svc("${sys.workdir}/inputs/param.txt"); } bundle agent svc(file) { vars: "dim_svc" int => readstringarray( "svc", "${file}", "\s*#[^\n]*", "\s*;;\s*", "100", "5k" ); "s" comment => "Get index of data array loaded above.", slist => getindices("svc"); reports: cfengine:: "dim_svc => ${dim_svc}"; "index => ${s}"; "element 0 ${svc[${s}][0]}"; "element 1 ${svc[${s}][1]}"; "element 2 ${svc[${s}][2]}"; "element 3 ${svc[${s}][3]}"; "element 4 ${svc[${s}][4]}"; "element 5 ${svc[${s}][5]}"; "element 6 ${svc[${s}][6]}"; "element 7 ${svc[${s}][7]}"; "element 8 ${svc[${s}][8]}"; } Read txt file: # param zero ;; one ;; two ;; three ;; four ;; five ;; six ;; seven ;; eight a ;; b ;; c ;; d ;; e ;; f ;; g ;; h Actual results: $ cf-agent -KIf ./service.cf R: dim_svc => 2 !! Method invoked repairs Where are the indices? Where are the other reports promises? Using version 3.4.0a1. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine