Junos 10.3 Junos XML Management Protocol Guide
Tutorial: Writing Perl Client Applications
Import Perl Modules and Declare Constants
210
Make sure that the
PERL5LIB
as detailed in "Unpacking and Installing the Junos XML Protocol Perl Client
Prerequisites Package" on page 208. Then create the makefile:
% perl Makefile.PL LIB=$PERL5LIB INSTALLMAN3DIR=$PERL5LIB/../man/man3
Test and install the application:
2.
% make
% make test
% make install
The Junos XML protocol Perl client application is installed and ready for use. For
information about the
JUNOS::Device
page by invoking the
man
% man JUNOS::Device
The sample scripts reside in
review and run these examples to acquire some familiarity with the client before writing
your own applications.
This tutorial explains how to write a Perl client application that requests operational or
configuration information from the Junos XML protocol server or loads configuration
information onto a device. The following sections use the sample scripts included in the
Junos XML protocol Perl distribution as examples:
Import Perl Modules and Declare Constants on page 210
Connect to the Junos XML Protocol Server on page 211
Submitting a Request to the Junos XML Protocol Server on page 217
Parsing and Formatting the Response from the Junos XML Protocol Server on page 226
Closing the Connection to the Junos XML Protocol Server on page 232
Include the following statements at the start of the application. The first statement
imports the functions provided by the
to connect to the Junos XML protocol server on a device. The second statement provides
error checking and enforces Perl coding practices such as declaration of variables before
use.
use JUNOS::Device;
use strict;
Include statements to import other Perl modules as appropriate for your application. For
example, several of the sample scripts import the following standard Perl modules, which
include functions that handle input from the command line:
—Includes functions for processing filenames.
File::Basename
—Includes functions for reading in keyed options from the command line.
Getopt::Std
,
, and
MANPATH
object and a list of valid queries, consult the man
command for the
JUNOS::Device
parent-directory/junoscript-perl-release/examples/
JUNOS::Device
environment variables are set
PATH
object:
. You can
object, which the application uses
Copyright © 2010, Juniper Networks, Inc.
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