Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Example: Configure and Refresh from the Master Source for a Script

date_range 29-Nov-23

The following example configures a master source file for an op script on a device running Junos OS. The remote source is defined as an HTTP URL. The example uses the master source to update the local copy of the script on the device.

Requirements

  • Routing, switching, or security device running Junos OS.

Overview

You can store a master copy of each script in a central repository. You can make changes to the master script in one place and then update the local copy of the script on devices where the script is enabled.

This example enables the op script iso.xsl on a device running Junos OS and then configures a master source location for the script. The remote source for the iso.xsl file is the HTTP URL http://my.example.com/pub/scripts/iso.xsl.

Once you configure the master source location, you refresh the local script by issuing the set refresh configuration mode command at the hierarchy level where you configured the script. In this example, you would issue the set refresh command at the [edit system scripts op file iso.xsl] hierarchy level.

Configuration

Procedure

Step-by-Step Procedure

To download, enable, and configure the master source location for the script:

  1. Copy the script to the /var/db/scripts/op/ directory on the device.

  2. In configuration mode, configure the file statement to enable the iso.xsl script.

    content_copy zoom_out_map
    [edit system scripts op]
    user@R1# set file iso.xsl
    
  3. To configure the master source for the iso.xsl file, include the source statement and source location at the [edit system scripts op file iso.xsl] hierarchy level.

    content_copy zoom_out_map
    [edit system scripts op file iso.xsl]
    user@R1# set source http://my.example.com/pub/scripts/iso.xsl
    
  4. Issue the commit and-quit command to commit the configuration and exit to operational mode.

    content_copy zoom_out_map
    [edit]
    user@R1# commit and-quit
    

Results

content_copy zoom_out_map
system {
    scripts {
        op {
            file iso.xsl {
                source http://my.example.com/pub/scripts/iso.xsl;
            }
        }
    }
}

Verifying the Script

Purpose

Verify that the script is on the device and enabled in the configuration.

Action

Issue the file list operational mode command to view the files in the specified directory. The detail option provides additional information such as permissions, file size, and modified date.

content_copy zoom_out_map
user@R1> file list /var/db/scripts/op detail

/var/db/scripts/op:
total 128
-rw-r--r--  1 root  admin  13897 Feb 10  2011 iso.xsl
...

Issue the show configuration system scripts op operational mode command to list the op scripts currently enabled on the device.

content_copy zoom_out_map
user@R1> show configuration system scripts op
file iso.xsl

Refreshing the Script from the Master Source

Step-by-Step Procedure

To refresh the local copy of the script from the master source file:

  1. In configuration mode, issue the set refresh command at the [edit system scripts op file iso.xsl] hierarchy level.

    content_copy zoom_out_map
    [edit system scripts op file iso.xsl]
    user@R1# set refresh
    

Verification

Verifying the Updated Script

Purpose

After refreshing the script, verify that the local copy is updated.

Action

Issue the file list operational mode command with the detail option to view the files in the specified directory. Verify that the modified date reflects the refreshed version.

content_copy zoom_out_map
user@R1> file list /var/db/scripts/op detail

/var/db/scripts/op:
total 128
-rw-r--r--  1 root  admin  14128 May 26  2011 iso.xsl
...
footer-navigation