Monday, January 15, 2018

Junos Op Script Hello World

This is example and demo uses Junos on-box script for hello world. Basically on-box script divide into 3: operational script (op script), commit script and event script. On this posting I will show you the very simple about op script.

# Running Op Script from operational mode


awa@JUNOS> show configuration system scripts 

op {
    file hello.slax;
    file show.slax;
}

{master:0}

awa@JUNOS> file list /var/db/scripts/op 

/var/db/scripts/op:

hello.slax
show.slax*

{master:0}

awa@JUNOS> file show /var/db/scripts/op/hello.slax 
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 / {

    {
  "Hello World";
    }
}

{master:0}

awa@JUNOS> op hello 
Hello World

{master:0}

awa@JUNOS> 

# Running Op Script from start shell

*not all op script can running from start shell

awa@JUNOS> start shell 

% cd /var/db/scripts/op
% ls -l
total 16
-rw-r--r—  1 awa  wheel  275 Jan  9 17:02 hello.slax
-rwxrws---  1 awa  wheel  442 Jan  8 16:29 show.slax
% cat hello.slax
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 / {

    {
  "Hello World";
    }
}
% cli op hello
Hello World

%

No comments: