Page 1 of 1
CGI in apache doesnt work,but works with intepreter
Posted: Mon Nov 27, 2006 6:49 pm
by a94060
Hello,i know you have been hearing from me a lot in the last 2 days. I was wondering why i can execute a script with perl but that same script gives me the Error 500 Misconfig error? Why is this? If i execute a simple script like :
Code: Select all
#!/usr/bin/perl
use DBI;
$dbh = DBI->connect('dbi:mysql:time','pass','pass')
or die "Connection Error: $DBI::errstr\n";
$sql = "select * from times WHERE hash = 249682";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
$rv = $sth->rows;
print $rv;
This returns 1 when i run thru perl script.cgi but when i access it from my site,it gives that error,why is this?[/syntax]
Posted: Mon Nov 27, 2006 8:41 pm
by volka
Is there something related in the file error.log of your apache installation?
Posted: Mon Nov 27, 2006 8:52 pm
by a94060
This is the top most lines of my log:
[Mon Nov 27 20:46:53 2006] [error] [client 10.10.10.30] Premature end of script headers: test.cgi
[Mon Nov 27 21:26:20 2006] [error] [client 10.10.10.30] Premature end of script headers: test.cgi, referer:
https://10.10.10.5/
[client 10.10.10.30] script '/var/www/logout.php' not found or unable to stat
[client 10.10.10.30] script '/var/www/logout.php' not found or unable to stat
[client 10.10.10.30] script '/var/www/logout.php' not found or unable to stat
[Mon Nov 27 22:50:39 2006] [error] [client 10.10.10.30] Premature end of script headers: test.cgi
What are script headers?
Posted: Tue Nov 28, 2006 1:04 am
by timvw
If i'm not mistaken it's the most common error since 199x... for Perl/CGI...
Code: Select all
#!/usr/bin/perl
use DBI;
print "Content-type: text/html\r\n\r\n";
print "Now it works.";
But if you consult a manual i'm pretty sure that throughout the years people have written libraries to do that for you...
(The
CGI documentation seems like a good place to start)
Posted: Tue Nov 28, 2006 2:26 pm
by a94060
thank you for showing me that, it seems to have solved the problem,ill post back here if i get a another problem.