1
我试图从infoblox设备显示一些信息。当我使用html post在浏览器中运行此代码时,显示MAC地址条目的表不显示api的值。当我在unix命令行中运行这些代码时,变量会适当地显示出来。任何建议?在浏览器中不显示结果的CGI脚本
#!/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);
什么是Infoblox?运行CGI应用程序的用户是否有权运行Infoblox? – choroba
Obligatory http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script – mob
Infoblox是一个DNS/DHCP/IPAM设备。用户不需要运行Infoblox的权限。 API包含对设备进行身份验证所需的凭据。 – RichDiet