Using RPCs and Operational Mode Commands
Most operational mode commands supported in the JUNOS software have XML equivalents known as remote procedure calls (RPCs). All operational mode commands that have XML equivalents are listed in the JUNOS XML API Operational Reference.
Using RPCs
To use an RPC in an op script, include the RPC in a variable declaration, as shown in the following snippet. This snippet is expanded and fully described in Customizing Output of the show interfaces terse Command.
<xsl:variable name="rpc"><get-interface-information/> # JUNOS RPC for the show interfaces command</xsl:variable><xsl:variable name="out" select="jcs:invoke($rpc)"/>...Using Operational Mode Commands
Some operational mode commands do not currently have XML equivalents (RPCs). If a command is not listed in the JUNOS XML API Operational Reference, the command does not have an XML equivalent. Another way to determine whether a command has an XML equivalent is to issue the command with the
| display xmlpiped command:user@host>operational-mode-command| display xmlIf the output of this command contains no more detail than the
<output>and<cli>tag elements, the command does not have an XML equivalent. For example, theshow hostcommand has no XML equivalent. The only child elements of the<rpc-reply>element are the<output>and<cli>tag elements:user@host>show hosthostname| display xml<rpc-reply xmlns:junos="http://xml.juniper.net/junos/7.6I0/junos"><output>...</output><cli><banner></banner></cli></rpc-reply>You can reference commands that have no XML equivalent. You can do this by including the
<command>,<xsl:value-of>, and<output>elements, as shown in the following snippet. This snippet is expanded and fully described in Displaying DNS Hostname Information.<xsl:variable name="query"><command><xsl:value-of select="concat('show host ', $hostname)"/></command></xsl:variable><xsl:variable name="result" select="jcs:invoke($query)"/><xsl:variable name="host" select="$result"/><output><xsl:value-of select="concat('Name: ', $host)"/></output>...