output() Function (Python, SLAX, and XSLT)
Namespaces
http://xml.juniper.net/junos/commit-scripts/1.0 http://xml.libslax.org/slax
Python Syntax
jcs.output(string, <string>)
SLAX Syntax
expr prefix:output(string, <string>);
XSLT Syntax
<xsl:value-of select="prefix:output(string, <string>)"/>
Description
Display one or more lines of output text, either on the CLI (when used in op scripts), or to the output file (when used in event scripts). The script can call the function with a single string argument or with multiple string arguments. Multiple arguments are concatenated into a single string. A newline terminates the output text.
Commit scripts do not support the output() function. SLAX and XSLT
commit scripts use the <xnm:warning> and
<xnm:error> result tree elements to display text on the
CLI. Python commit scripts use the emit_warning() and
emit_error() functions.
The output() function displays the text immediately rather than
waiting until the conclusion of the script, which differs from the SLAX and XSLT
<output> element. This makes it suitable for scripts that
require user interaction or that need to display status messages during execution.
In SLAX and XSLT scripts, jcs:output() returns an empty node set,
which can be ignored. Therefore, you normally use the expr
statement to call the jcs:output() function, rather than assigning
its result to a variable.
The following escape characters are supported in the output text:
-
\\ –Backslash
-
\r –Carriage Return
-
\" –Double quote
-
\n –Newline
-
\' – Single quote
-
\t –Tab
The maximum length for output text is 10 KB, and longer strings are truncated to the supported length.
The prefix associated with the namespace URI should be defined in the prefix-to-namespace mapping in the style sheet.
Parameters
string |
Text that is output immediately to the CLI session. |
Usage Examples
Python syntax:
jcs.output('The VPN is up.')
SLAX syntax:
expr jcs:output('The VPN is up.');XSLT syntax:
<xsl:value-of select="jcs:output('The VPN is up.')"/>Release Information
Function introduced in Junos OS Release 7.6.
Support for the slax namespace http://xml.libslax.org/slax added in Junos OS Release 12.2.
Support for Python added in Junos OS Release 16.1R1.