Forms CGI脚本不在浏览器中显示结果
我试图显示infoblox设备中的一些信息。当我在浏览器中使用html post运行此代码时,显示MAC地址条目的表不会显示api中的值。当我在unix命令行中运行这段代码时,变量会相应地显示出来。有什么建议吗Forms CGI脚本不在浏览器中显示结果,forms,perl,cgi,Forms,Perl,Cgi,我试图显示infoblox设备中的一些信息。当我在浏览器中使用html post运行此代码时,显示MAC地址条目的表不会显示api中的值。当我在unix命令行中运行这段代码时,变量会相应地显示出来。有什么建议吗 #!/usr/bin/perl use strict; use Infoblox; use CGI; my $cgi = new CGI; print $cgi->header() . $cgi->start_html( -title => 'Form Resu
#!/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);
#/usr/bin/perl
严格使用;
使用Infoblox;
使用CGI;
my$cgi=新cgi;
打印
$cgi->header()。
$cgi->start_html(-title=>“表单结果”)。
$cgi->h1(“表格结果”)。“\n”;
my@params=$cgi->param();
我的$username=$cgi->param('username');
打印“”。“\n”;
foreach my$参数(sort@params){
打印“$parameter”。$cgi->param($parameter)。“\n”;
}
打印“\n”;
打印“$username”;
打印$cgi->end_html。“\n”;
#创建到Infoblox设备的会话
my$session=Infoblox::session->new(
主机=>“服务器”#设备主机ip
用户名=>“用户名”,#设备用户登录
密码=>“密码”#设备密码
);
除非($session){
die(“构造会话失败:”,
Infoblox::status_code().“:”.Infoblox::status_detail());
}
打印“会话创建成功\n
”;
我的@list=$session->get(
object=>“Infoblox::DHCP::MAC”,
过滤器=>“macfilter”,
);
my$nextobject=$list[0];
打印注释()。“\n”;
打印“”。标量($test->username())。“\n”;
打印“”。标量(localtime(标量($test->expiration\u time()))。“\n”;
打印“”;
}
出口(0);
我的权限不正确。脚本以用户身份运行,无法在网页上正确显示项目 什么是Infoblox?运行CGI应用程序的用户是否具有运行Infoblox的权限?Infoblox是一个DNS/DHCP/IPAM设备。用户不需要运行Infoblox的权限。API包含对设备进行身份验证所需的凭据。您是否已验证@list是否包含任何数据?e、 上面有g.us Data::Dumper()?是的。该列表包含与MAC筛选器条目相对应的哈希值。我想我错过了一个$ENV{PATH}。我也试过使用setuid。