Forum: CFEngine Help
Subject: Re: Odd behaviour of splitstring
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,25023,25069#msg-25069

To verify this, you can see that the following does print all the lines, since 
in this case each reports: promiser is different due to the line numbers (cat 
-n):

bundle agent iptables_save
{
  vars:
      "raw" string => execresult( "/bin/cat -n /tmp/input.txt", "noshell");
      "lines" slist => splitstring( "${raw}", "\n", "100000");
      "no_comments" slist => grep( ".*?[^#]*", "lines" );

  reports:
    cfengine::
      "raw: ${raw}";
      "lines: ${lines}";
      "no_comments: ${no_comments}";
}

Depending on what operations you want to do on the input, maybe it would be 
easier to do this with a template? (Sneak preview: there's a very cool new 
templating system on the way).

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

Reply via email to