Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Using an Alternate Source Location for a Script

Refreshing a Script from an Alternate Location

In addition to updating a script from the master source defined by the source statement, you also can update a script from an alternate location using the set refresh-from configuration mode command. This is convenient when, for example, the master source cannot be accessed due to network issues or other problems.

The update operation occurs as soon as you issue the set refresh-from command. When you issue the set refresh-from command, the switch, router, or security device immediately attempts to connect to the specified URL and retrieve a copy of the file. The copy overwrites the local script stored in the scripts directory on the device. If a copy of the source is not available, that script is not updated and a warning is issued. For commit scripts, the updated commit script is executed when you next issue the commit command. You can also refresh a single script from the remote location by issuing the request system scripts refresh-from operational mode command and specifying the URL for the remote script.

Issuing the set refresh-from command does not add the refresh-from statement to the configuration. Thus the set refresh-from command behaves like an operational mode command by executing an operation, instead of adding a statement to the configuration.

If a device has dual Routing Engines and you want the script to be updated on both Routing Engines, you must issue the set refresh-from command on each Routing Engine separately. The commit synchronize command does not cause the refresh-from statement to update scripts on both Routing Engines.

When you issue the set refresh-from command, Junos OS creates a folder in the /var/tmp directory. This folder is used for file transfer. After the transfer and refresh operations are complete, Junos OS deletes the temporary folder.

To update a single script from the alternate source, issue the set refresh-from command at the hierarchy level where the script is configured, and specify the location of the remote file.

  • commit script—Issue the set refresh-from command at the [edit system scripts commit file filename] hierarchy level.

    [edit system scripts commit file filename]user@R1# set refresh-from url
  • op script—Issue the set refresh-from command at the [edit system scripts op file filename] hierarchy level.

    [edit system scripts op file filename]user@R1# set refresh-from url
  • event script—Issue the set refresh-from command at the [edit event-options event-script file filename] hierarchy level.

    [edit event-options event-script file filename]user@R1# set refresh-from url

To update all enabled scripts of a given script type from an alternate source, issue the set refresh-from command at the hierarchy level for that script type, and specify the location of the remote directory that houses the scripts.

  • commit script—Issue the set refresh-from command at the [edit system scripts commit] hierarchy level.

    [edit system scripts commit]user@R1# set refresh-from url
  • op script—Issue the set refresh-from command at the [edit system scripts op] hierarchy level.

    [edit system scripts op]user@R1# set refresh-from url
  • event script—Issue the set refresh-from command at the [edit event-options event-script] hierarchy level.

    [edit event-options event-script]user@R1# set refresh-from url

Where

url—URL of the remote script or directory. Specify the source as a Hypertext Transfer Protocol (HTTP) URL, FTP URL, or secure copy (scp)-style remote file specification.

Example: Refreshing a Script from an Alternate Source

The following example uses an alternate source location to update the local copy of the script on a device running Junos OS. The remote source is defined as an HTTP URL.

Requirements

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

Overview

You can update a script from a location other than that of the master source. This is convenient when, for example, the master source cannot be accessed due to network issues or other problems. You can refresh a single script or all scripts of a given type from the alternate location.

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

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

Configuration

Step-by-Step Procedure

To download and enable 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.

    [edit system scripts op]user@R1# set file iso.xsl
  3. Issue the commit and-quit command to commit the configuration and exit to operational mode.

    [edit]user@R1# commit and-quit

Results

system {scripts {op {file 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.

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.

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

Refreshing the Script from the Alternate Location

Step-by-Step Procedure

To refresh the local copy of the script from the alternate location:

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

    [edit system scripts op file iso.xsl]user@R1# set refresh-from http://my.example.com/pub/scripts2/iso.xsl

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.

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
...

Published: 2013-03-05