Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual page 251

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Copyright © 2010, Juniper Networks, Inc.
outconfig( $basepath, $hostname, $config, $opt{t} );
In the first lines of the preceding sample code, the
statements to obtain values for the four parameters to the
If the user provides the
-t
it in the
hash. The value keyed to
%opt
the
outconfig
subroutine. (For more information about reading options from the
command line, see "Example: Collecting Parameters Interactively" on page 212.)
getopts('l:p:dm:hit', \%opt) || output_usage();
The following line reads the first element of the command line that is not an option
preceded by a hyphen. It assigns the value to the
of the directory in which to store the file containing the output from the
subroutine. The variable value is passed as the first parameter to the
subroutine.
my $basepath = shift || output_usage;
The following line reads the next element on the command line. It assigns the value
to the
variable, defining the routing, switching, or security device hostname.
$hostname
The variable value is passed as the second parameter to the
my $hostname = shift || output_usage;
The following line invokes the
the Junos XML protocol server on the specified device, assigning the resulting XML
DOM tree to the
$config
to the
subroutine.
outconfig
my $config = getconfig( $hostname, $jnx, $opt{t} );
The following code sample invokes and defines the
discussion of each functional subsection in the subroutine follows the complete code
sample.
outconfig( $basepath, $hostname, $config, $opt{t} );
sub outconfig( $$$$ ) {
my $leader = shift;
my $hostname = shift;
my $config = shift;
my $text_mode = shift;
my $trailer = "xmlconfig";
my $filename = $leader . "/" . $hostname . "." . $trailer;
print "# storing configuration for $hostname as $filename\n";
my $config_node;
my $top_tag = "configuration";
$top_tag .= "-text" if $text_mode;
if ($config->getTagName() eq $top_tag) {
$config_node = $config;
} else {
print "# unknown response component ", $config->getTagName(), "\n";
Chapter 9: Writing Junos XML Protocol Perl Client Applications
get_config.pl
option on the command line, the
is passed as the fourth parameter to
$opt{t}
$basepath
getconfig
subroutine to obtain configuration data from
variable. The variable value is passed as the third parameter
outconfig
script uses the following
outconfig
subroutine:
subroutine records
getopts
variable, defining the name
outconfig
outconfig
subroutine.
outconfig
subroutine. A detailed
229

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Junos os

Table of Contents