1

I am attempting to display some info from an infoblox device. When I run this code in a browser using an html post, the table that displays MAC address entries does not display the values from the api. When I run this code in the unix command-line, the variables show up appropriately. Any Advice?

#!/usr/bin/perl

use strict;
use Infoblox;
use CGI;
my $cgi = new CGI;

print

$cgi->header() .

$cgi->start_html( -title => 'Form Results') .

$cgi->h1('Form Results') . "\n";

my @params = $cgi->param();
my $username = $cgi->param('username');
print '<table border="1" cellspacing="0" cellpadding="0">' . "\n";
foreach my $parameter (sort @params) {
print "<tr><th>$parameter</th><td>" . $cgi->param($parameter) . "</td></tr>\n";
}
print "</table>\n";
print "<p>$username</p>";

print $cgi->end_html . "\n";



#Create a session to the Infoblox appliance
my $session = Infoblox::Session->new(
    master   => "server",          #appliance host ip
    username => "username",          #appliance user login
    password => "password"           #appliance password
);

unless ($session) {
    die("Construct session failed: ",
    Infoblox::status_code() . ":" . Infoblox::status_detail());
}

print "Session created successfully\n<br>";

my @list = $session->get(
    object => "Infoblox::DHCP::MAC",
    filter => "macfilter",
);

my $nextobject = $list[0];

print <<EOF;
<br>
<table>
<tr>
<th>MAC</th>
<th>Description</th>
<th>UserID</th>
<th>Expiration</th>
</tr>
EOF

foreach my $test ( @list ) {

   print "<tr>";
   print "<td> $test->mac()</td>";
   print "<td>" . scalar($test->comment()) . "</td>\n";
   print "<td>" . scalar($test->username()) . "</td>\n";
   print "<td>" . scalar(localtime(scalar($test->expiration_time()))) . "</td>\n";
   print "</tr>";

}

exit (0);
Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
RichDiet
  • 13
  • 3
  • 1
    What is Infoblox? Does the user that runs your CGI application have the permissions to run Infoblox? – choroba Nov 05 '12 at 17:02
  • Obligatory http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script – mob Nov 05 '12 at 17:49
  • Infoblox is a DNS/DHCP/IPAM appliance. The user does not need permissions to run Infoblox. The API contains the credentials necessary to authenticate against the device. – RichDiet Nov 06 '12 at 14:44
  • Have you verified that @list has any data? e.g. us Data::Dumper() on it? – Craig Treptow Nov 06 '12 at 15:16
  • Yes. The list contains the hashes that correspond to MAC filter entries. I'm thinking I am missing a $ENV{PATH}. I tried doing setuid as well. – RichDiet Nov 06 '12 at 15:28

1 Answers1

0

I had incorrect permissions. The script was running as user nobody and would not display the items correctly on the web page.

RichDiet
  • 13
  • 3