CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: mod_perl:
snmp and mod_perl



May 2, 2009, 10:20 AM

Post #1 of 1 (10993 views)
snmp and mod_perl Can't Post

SOLVED: Solution: Removed comments at the beginning and had the shebang line as the first line.


Im having problems running perl scripts that is using Net::SNMP, they just hang or im getting the message "(8)Exec format error".

Below is the messages from the apache error log (when running the

[Sat May 02 18:51:25 2009] [error] [client] (8)Exec format error: exec of '/usr/local/apache2/cgi-bin/' failed 
[Sat May 02 18:51:25 2009] [error] [client] Premature end of script headers:
[Sat May 02 19:03:48 2009] [error] [client] (8)Exec format error: exec of '/usr/local/apache2/cgi-bin/' failed
[Sat May 02 19:03:48 2009] [error] [client] Premature end of script headers:

When i run the i get an internal server error. The script runs without problems from the command-line. Does apache need some kind of snmp support ? I searched google and looked at but couldnt find anything about this.

Code for

#!/usr/bin/perl -w 

# load the necessary snmp module
use Net::SNMP ;

print "content-type: text/html\n\n" ;

# operative status for interface eth1
my @oid = qw("") ;

my $query = Net::SNMP->session(
hostname => "localhost",
port => 161,
version => "2c",
community => "password"
) ;

# checking if the snmp session was created without problems.
if (!defined($query)) {
print "An error occured while creating the SNMP session\n" ;
print "\nSNMP session created successfully.\n" ;

my $oidResult = $query->get_request("") or print $query->error ;

# checking if we got an answer
if (!defined($oidResult)) {
print "\noid was not received\n" ;
print "\noid received\n" ;

# is the interface up or down?
if ( $oidResult->{""} == 1 ) {
print "\nInterface is UP\n" ;
else {
print "\ninterface is DOWN\n" ;

exit 0 ;

Other perl scripts that are not using any module are working fine, for example a test script that just prints out all the elements in an array. Does someone know why the perl script is not executing correctly ? Any help is appericiated.

The apache configuration for the directory the scripts are executing in is the following:

<Directory "/usr/local/apache2/cgi-bin"> 
AllowOverride None
Options None
Order allow,deny
Allow from all

The has 755 permission bits.

(This post was edited by exceed on May 2, 2009, 10:33 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives