« Back to Administration XML Questions

RE: Help making list form query results perl and soap lite

Combination View Flat View Tree View
Threads [ Previous | Next ]
I have a query which returns several rows of data which is in bold.  When I print the result $res, it prints all results but not in a nice format.  Something like:  'Desc 1Desc 2Desc 3' and so on.  If I concatenate a newline character, it only prints the first value.  How do I get it to print the results as a nice list.  It is probably obvious but I'm drawing a blank. 
 
code below:
 
#!/Program Files/Cisco/perl
use strict;
use warnings;
use SOAP::Lite +trace => 'debug';
use Data:emoticonumper;
use MIME::Base64;
#define variables
my $cucmip;
my $axl_port = "8443";
my $user;
my $password;
my $error_text;
my $sql = "select description from device where description like '%Eri%'";
#get CUCM IP, username and password
print "Communications Manager IP: ";
$cucmip = <>;
print "AXL Username: ";
$user = <>;
chomp($user);
print "AXL User Password: ";
$password = <>;
chomp($password);
#set up soap
my $cm = new SOAP::Lite
encodingStyle => '',
uri => 'http://www.cisco.com/AXL/API/1.0',
proxy => "https://$cucmip:$axl_port/axl/" ;
#disable certificate check
BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 }
#authenticate to CUCM
$cm = Login($cm,"$user","$password");
#axl request
my $axldata = SOAP:emoticonata->name( "sql" => $sql );
my $res = $cm->executeSQLQuery( $axldata );
#show the returned value
unless ($res->fault)
{
 print $res ->valueof('//description');
}
else
{
 $error_text = $res->faultcode.' '.$res->faultstring."\n";
 print $error_text
}
################################################
sub Login
{
 $cm->transport->http_request->header (
 'Authorization' => 'Basic ' . encode_base64("$user:$password", ''));
 return $cm;

Hi Erick,

I think this should accomplish what you're looking for:

unless ($res->fault) {
my( $reply ) = $res->paramsall();
$desc = $reply->{row};
foreach(@$desc) {
print "$_->{description}\n";
}
}

HTH!

Marty

That does it. I just had to declare $desc. Learning more and more about Perl every day!


Thanks!

Hey Erick,

Glad it worked for you! I'm in the same boat man. Perl is a lot of fun and this same issue really gave me some trouble for a bit.

Good luck!

Marty