[j-nsp] understand the index in jcs:break-lines() function in SLAX

Martin T m4rtntns at gmail.com
Thu Jan 14 12:38:42 EST 2016


Hi,

jcs:break-lines() function in SLAX allows one to break content into
multiple lines. For example here I break the output of "show chassis
mac-addresses" into lines:

version 1.0;

ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

match / {
  <op-script-results> {

    var $sh_mac_results = jcs:invoke( "get-chassis-mac-addresses" );
    var $line = jcs:break-lines( $sh_mac_results );
    <output> $line;

  }
}

However, script above returns an empty line. Now if I add for example
index "0" or "1" to "$line" variable, then nothing changes. If I add
index "2"(e.g <output> $line[2];), then the first line of "show
chassis mac-addresses" command is printed:

root at M10i> op RE
MAC address information:

root at M10i>

How are those indexes numbered? Only thing that I can think of is that
those are indexed from zero and first line is "<rpc-reply
xmlns:junos="http://xml.juniper.net/junos/13.3R8/junos">" which is not
printed, second line is "<output>" which is also not printed and then
the third line would be "MAC address information:". However, I could
easily be wrong. Indexes in jcs:regex() are well documented and
logical, but I could not find any information regarding indexes for
jcs:break-lines() function..



thanks,
Martin


More information about the juniper-nsp mailing list