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

Execute an Op Script on the Local Device

date_range 29-Nov-23

Unlike commit scripts, operation (op) scripts do not execute during a commit operation. When you issue the commit command, op scripts configured at the [edit system scripts op] hierarchy level are placed into system memory and enabled for execution. After the commit operation completes, you can execute an op script from the CLI by issuing the op command in operational mode. You also can configure the device to execute an op script automatically when a member of a specific Junos OS login class logs in to the CLI.

Executing an Op Script by Issuing the op Command

To execute an op script from the CLI, issue the op command, and specify a script filename, a script alias as defined by the command statement at the [edit system scripts op file filename] hierarchy level, or a URL.

content_copy zoom_out_map
user@host> op (filename | filename-alias | url url)

For more information about executing op scripts from a remote site using op url, see Execute an Op Script from a Remote Site.

Note:

In order to execute Python op scripts from a remote site, you must configure the allow-url-for-python statement at the [edit system scripts op] hierarchy level.

Executing an Op Script at Login

You can configure an op script to execute automatically when any user belonging to a designated Junos OS login class logs in to the CLI. To associate an op script with a login class, include the login-script filename statement at the [edit system login class class-name] hierarchy level.

content_copy zoom_out_map
[edit system login]
class class-name {
    login-script filename;
}

The following example configures the super-user-login.slax op script to execute when any user who belongs to the super-user class logs in to the CLI (provided that the script has been enabled as discussed in Enable an Op Script and Define a Script Alias).

content_copy zoom_out_map
[edit system login]
class super-user {
    login-script super-user-login.slax;
}
footer-navigation