Chapter 1 Using the CLI
17
The example shows a Perl script for logging in.
cLogin
is called at the start of the
script to log a user into the CLI. The script uses the command-line parameters
specified as the IP address, username, and password. Once the user has been logged
in, other commands can be sent to the CLI.
The command below provides better scripting support. The first argument sets the
output format to XML, which allows easier parsing. The second argument disables
the paging mode that pauses for each full screen of command output.
The following code segment shows how to get the entire configuration information
from the CLI and print the output. The output can easily be redirected to a file for
archiving.
Using the XML API
You can set the CLI output to either
console
or
api
using the
set cli-
parameters
command. When set to
api
, the output is returned in XML. You can
use an XML parser such
XML::Parser
in Perl to process the XML output and
store this information as objects.
An updated Document Type Definition (DTD) is available with each update of the
firmware. The DTD is located on the Customer Resource Center web site. Go to:
http://crc.dothill.com
> R/Evolution Products > Software Downloads search
for the DTD in the article list.
if ( !cLogin($ipAddr, $username, $password) == 1 )
{
print("Error: $username user failed to log in. Exiting.\n");
$telnet->close;
exit(0);
}
$telnet->cmd("set cli-parameters api pager disabled");
@sV = $telnet->cmd("show configuration");
for ($i=0; $i<scalar(@sV); $i++)
{
print (“@sV[ $i ]”);
}
Summary of Contents for RPC12 Series
Page 1: ......
Page 11: ...12 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 29: ...30 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 35: ...36 Phoenix RPC12 Series CLI Reference Manual September 2008...
Page 227: ...228 Phoenix RPC12 Series CLI Reference Manual September 2008...