[j-nsp] read CLI "banner" XML element value with SLAX script
Martin T
m4rtntns at gmail.com
Wed Jan 13 06:49:31 EST 2016
Hi,
Junos has "banner" XML element under "rpc-reply" and "cli" hierarchy:
<rpc-reply>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Is it somehow possible to read the value of "banner" element with SLAX
script? For example I have a router with dual routing-engines, i.e
"banner" element has either value of "{master}" or "{backup}":
{master}
root at M10i> show version brief | display xml | find cli
<cli>
<banner>{master}</banner>
</cli>
</rpc-reply>
{master}
root at M10i>
Now if I try to print the value of "banner" element, then this does not work:
{master}
root at M10i> file show /var/db/scripts/op/show-banner.slax
version 1.0;
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
match / {
<op-script-results> {
var $sh_ver_cmd = <command> "show version brief";
var $sh_ver_cmd_out = jcs:invoke( $sh_ver_cmd );
var $banner_var = $sh_ver_cmd_out//banner;
<output> $banner_var;
}
}
{master}
root at M10i> op show-banner
{master}
root at M10i>
Is there a way to process everything between <rpc-reply></rpc-reply>
elements? I'm afraid that my script processes data between
<software-information> and </software-information> elements.
thanks,
Martin
More information about the juniper-nsp
mailing list