Automation
Automation

Scripting How-To: Commit Op scripts in private mode

by Juniper Employee on ‎02-12-2016 02:27 PM - edited on ‎09-19-2017 09:35 AM by Administrator Administrator
02.12.16   |   02:27 PM

Overview

This topic describes how to commit Op scripts in private mode.

 

Example Configuration

 

This example shows how you commit an Op script in a private configuration session.

 

 var $connection = jcs:open();
var $edit-private = <open-configuration> { <private>; }
/* adding the log message is optional, but considerate */
var $commit-config = <commit-configuration> { <log> "Changed by script: " _ $script; }
var $configuration = <load-configuration> {
     <configuration> {
        /* stuff goes here */
    }
/* please check/report on errors or warnings on each of $res1-4 */
var $res1 = jcs:execute( $connection, $edit-private );    /* open private session */
var $res2 = jcs:execute( $connection, $configuration );   /* load your config change */
 var $res3 = jcs:execute( $connection, $commit-config );  /* commit your config */
 var $res4  = jcs:execute( $connection, 'close-configuration' );  /* close up */
 expr jcs:close( $connection );    /* may not be needed if script is exiting here */
}