2012-11-05 99 views
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); 
+1

什麼是Infoblox?運行CGI應用程序的用戶是否有權運行Infoblox? – choroba

+0

Obligatory http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script – mob

+0

Infoblox是一個DNS/DHCP/IPAM設備。用戶不需要運行Infoblox的權限。 API包含對設備進行身份驗證所需的憑據。 – RichDiet

回答

0

我有不正確的權限。該腳本以nobody用戶身份運行,並且不會在網頁上正確顯示這些項目。

相關問題