What distribution are you running this on?? The perl script I wrote works as follows
Code:
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
print $query->header;
print "<html>\n";
print "<head>\n";
print "<title>ntop startup script</title>\n";
print "<STYLE TYPE='text/css'>\n";
print "h3 { color: red }\n";
print "a { text-decoration: none; font: bold 14pt/16pt Ariel, serif }";
print "a:hover { color: red } /* when mouse is over link */";
print "</style>\n";
print "</head>\n";
print "<body bgcolor='#c0c0d0'>\n";
print "<center>";
print "<p><br></p>";
print "<p><br></p>";
my $bb = `./ntop.sh stop` or die ($!);
sleep(5);
my $cc = `./ntop.sh start` or die ($!);
print "</body>";
print "</html>";
I created a simulated ntop.sh in the same directory as follows
Code:
#!/bin/bash
case "$1" in
start)
# is it the first time we run ntop
echo "Starting ntop"
;;
stop)
echo "Stopping ntop"
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exit 0
Here is the output after running the script:
Code:
[root@myweb ntop]# ./newtop.cgi
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<title>ntop startup script</title>
<STYLE TYPE='text/css'>
h3 { color: red }
a { text-decoration: none; font: bold 14pt/16pt Ariel, serif }a:hover { color: red } /* when mouse is over link */</style>
</head>
<body bgcolor='#c0c0d0'>
<center><p><br></p><p><br></p>Stopping ntop
Starting ntop
</body></html>[root@myweb ntop]#
Your not running SElinux are you? I would check the /var/log/messages for entries as follows
Jul 23 12:02:22 myweb kernel: audit(1122141742.771:0): avc: denied { search } for pid=6906 exe=/bin/bash dev=devpts ino=1 scontext=root:system_r:httpd_sys_script_t tcontext=user_u:object_r:devpts_t tclass=dir
Jul 23 12:02:22 myweb kernel: audit(1122141742.772:0): avc: denied { search } for pid=6906 exe=/bin/bash dev=devpts ino=1 scontext=root:system_r:httpd_sys_script_t tcontext=user_u:object_r:devpts_t tclass=dir
This indicates that SElinux does not allow execution of the ntop.sh script by httpd_sys_script_t tcontext
Also it might be Carp croaking your script before it has a chance to run.
Try commenting out the
Code:
BEGIN
{
use CGI::Carp qw(carpout);
my $errorlog = "/var/tmp/errorlog.txt";
open(LOG, ">$errorlog") or die("Unable to open $errorlog: $!\n");
print LOG "Errors:\n";
carpout(*LOG);
}
and rerun the script.
Sorry if this is a lot of dense text