Declaring Arguments
There are two ways to declare arguments to an op script: with XSLT instructions in the script or with JUNOS statements in the configuration. Script-generated and configuration-generated arguments have the same operational impact.
To declare arguments within a script, declare an XSLT global variable named
arguments, containing<argument>tag elements. Within each<argument>tag element, include the required<name>tag element and the optional<description>tag element:<xsl:variable name="arguments"><argument><name>name</name><description>name</description></argument><argument><name>cli-help-text</name><description>cli-help-text</description></argument></xsl:variable>To declare arguments in the configuration, include the
argumentsstatement at the[edit systemscriptsopfilefilename]hierarchy level:[edit systemscriptsop filefilename]arguments {name{descriptioncli-help-text;}}If you include the optional
<description>tag element or thedescriptionstatement, the text of the description appears in the command-line interface (CLI) as a help-text string to describe the purpose of the argument, as discussed in Configuring Command-Line Help Text.In the op script, you must include a corresponding parameter declaration for each argument. The parameter name must match the name of the argument:
<xsl:param name="name"/>You can create a hidden argument by including the
<xsl:param name="name"/>instruction without listing the argument in theargumentsvariable or in the configuration.After you declare an argument, you can use command completion to list available arguments:
user@host>opfilename?Possible completions:argument-name descriptionargument-name descriptionFor each argument you include on the command-line, you must specify a corresponding value for the argument. To do this, include an
argument-nameand anargument-valuewhen you execute the script with theopfilenamecommand:user@host>opfilename argument-name argument-valueExample: Declaring Arguments
Declare two arguments named
interfaceandprotocol. Execute the script, specifying the ge-0/2/0.0 interface and the inet protocol as values for the arguments. For either method, you must declare corresponding script parameters:<xsl:param name="interface"/><xsl:param name="protocol"/>Method 1:
In the script1 Op Script<xsl:variable name="arguments"><argument><name>interface</name><description>Name of interface to display</description></argument><argument><name>protocol</name><description>Protocol to display (inet, inet6)</description></argument></xsl:variable>Method 2:
In the Configurationsystem {scripts op {file script1 {arguments {interface {description "Name of interface to display";}protocol {description "Protocol to display (inet, inet6)";}}}}}Executing the Script
user@host>op script1 interface ge-0/2/0.0 protocol inet