Sunday, March 30, 2014

Op script - Sort of an array

Defining ENUM-like data structure in the script itself. A simple tutorial script on how to sort via slax.


[edit]
jnpr@Boomer-RE0# run op array    
10.10.10.3
10.10.10.2
10.10.10.1

---------------
version 1.0;
 
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
 
import "../import/junos.xsl";
 
match / {
    <op-script-results> {
        <output method= "text"> {

            var $enum := {
               <ipaddr>"10.10.10.1";
               <ipaddr>"10.10.10.2";
               <ipaddr>"10.10.10.3";
            }


            for-each ($enum/ipaddr) { 
                <xsl:sort select = "." order = "descending">;
                expr . _ "\n";
            }
        }
    }
}

No comments:

Post a Comment