Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Storing Scripts in Flash Memory
- Storing and Using Imported Scripts and Script Functionality
- Controlling Execution of Commit Scripts During Commit Operations
- ACX, EX, M, MX, PTX, QFX, T Series
- load-scripts-from-flash (Scripts)
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.
- Create the script.
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.
- commit script—Copy the script to the
Enable the script by including the file filename statement at the appropriate hierarchy level for that script type.
commit script—Include the file filename statement at the [edit system scripts commit] hierarchy level. For instructions, see Controlling Execution of Commit Scripts During Commit Operations.
op script—Include the file filename statement at the [edit system scripts op] hierarchy level. For instructions, see Enabling an Op Script and Defining a Script Alias.
event script—Include the file filename statement at the [edit event-options event-script] hierarchy level. For instructions, see Enabling an Event Script.
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-flashIssue 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.
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Storing Scripts in Flash Memory
- Storing and Using Imported Scripts and Script Functionality
- Controlling Execution of Commit Scripts During Commit Operations
- ACX, EX, M, MX, PTX, QFX, T Series
- load-scripts-from-flash (Scripts)
Published: 2013-07-26
Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Storing Scripts in Flash Memory
- Storing and Using Imported Scripts and Script Functionality
- Controlling Execution of Commit Scripts During Commit Operations
- ACX, EX, M, MX, PTX, QFX, T Series
- load-scripts-from-flash (Scripts)