Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Storing and Enabling Scripts

To use a script on a switch, router, or security device, you must copy the script to the device and enable it in the configuration.

  1. Create the script.
  2. Copy the script to the appropriate directory on the device for that script type. Only users who belong to the Junos OS super-user login class can access and edit files in the script directories on a device running Junos OS.

    By default, scripts are stored in and executed from the /var/db/scripts directory on the device's hard drive under the subdirectory appropriate to the script type. You can also store scripts on the flash drive in the /config/scripts directory under the subdirectory appropriate to the script type.

    • commit script—Copy the script to the /var/db/scripts/commit directory on the hard drive or the /config/scripts/commit directory on the flash drive.
    • op script—Copy the script to the /var/db/scripts/op directory on the hard drive or the /config/scripts/op directory on the flash drive.
    • event script—Copy the script to the /var/db/scripts/event directory on the hard drive or the /config/scripts/event directory on the flash drive.

    Note: If the device has dual Routing Engines and you want to enable the script to execute on both Routing Engines, you must copy it to the appropriate directory on both Routing Engines. The commit synchronize command does not automatically copy scripts between Routing Engines.

  3. Enable the script by including the file filename statement at the appropriate hierarchy level for that script type.

  4. If you store scripts in and load them from flash memory, include the load-scripts-from-flash statement at the [edit system scripts] hierarchy level. For detailed information about storing scripts in flash memory, see Storing Scripts in Flash Memory.

    [edit]user@host# set system scripts load-scripts-from-flash
  5. Issue the commit command.

    [edit]user@host# commit

Newly enabled commit scripts do not execute during the commit operation but execute automatically during each subsequent commit operation. After the commit operation completes, enabled event scripts are loaded into memory and are ready for automatic execution in response to system log events. For more information, see Executing Event Scripts in an Event Policy. After the commit operation completes, op scripts can be executed on the device. For more information, see Executing an Op Script.

Published: 2012-11-05