CGI in apache doesnt work,but works with intepreter

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

CGI in apache doesnt work,but works with intepreter

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Is there something related in the file error.log of your apache installation?
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post 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.
Post Reply