Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi doesnt work internal server error

Status
Not open for further replies.

robertd18

Technical User
Jan 14, 2003
32
US
its not permissions , path to perl, a script problem, or an
ascII transfer problem, it says bad intrepreter
uses perl 5.8.0
 
Robert,

Have a good look at your post and see if there's enough information that anyone could make sense of.

Paul
 
it says premature end of script headers in error log
 
A common problem that produces that is printing the content type at the start of the HTML stream.

Try putting this in as the first line of data that is output to the browser

Code:
print "Content-type:text/html\n\n";

Or if you're using CGI.pm
Code:
print header();

HTH
Paul
 
this maybe will help all the perl programs are not working but everything else is...could it be something in apache conf?
 
The malformed header error message means that the server has started serving the output.

Can you post some code

Paul
 
#!/usr/bin/perl -w


#############################################################################
#############################################################################
## ##
## ________ __ _ __ __ ##
## / _______| | | |_| \ \ / / ##
## | | | | _ \ \ / / ##
## | | | | | | \ \/ / ##
## | | | | | | / /\ \ ##
## | |______ | |_____ | | / / \ \ ##
## \________| \_______| |_| /_/ \_\ ##
## ##
## Script by CLiX ##
#############################################################################
#############################################################################
## Home Xchange Version 1.0 ##
## Created 7/16/01 Created by CLiX ##
## CopyRight © 2001 CLiX clix@theclixnetwork.com ##
## Get other scripts at: theclixnetwork.com ##
#############################################################################
#############################################################################
$num = "45";
$activemin = "50";
## PERCENT CHANCE OF REG RANDOM SELECTION

srand;
require "clix-cgi.pl";
$username = $ENV{'QUERY_STRING'};

open(FILE, &quot;config.dat&quot;); $a = @config = <FILE>; close FILE; for ($i=0; $i<$a; $i++) { chomp($config[$i]); }
@USER = getfile(&quot;$config[7]/$username&quot;);
&printhead;
$frm2 = int(rand(100)) . &quot;f&quot;;
$frm3 = int(rand(100)) . &quot;f&quot;;
$checkedreg = &quot;0&quot;;
$checkedpriority = &quot;0&quot;;
$checkedtop = &quot;0&quot;;
srand;
$thecat = $USER[24];
$user = &quot;KDK&quot;;
$vx = int(rand(100));
if ($vx <= $num) { &reguser; } elsif ($vx > 55) { &priorityuser; } else { &topactive; }

sub topactive {
debug(&quot;TA user&quot;);
$checkedtop = &quot;1&quot;;
srand;
$tot = @DB = getfile(&quot;./categories/$thecat&quot;);
debug(&quot;The Cat:$thecat&quot;);
$numba = int(rand($tot));
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
if (-e &quot;$config[7]/$DB[$jjj]&quot;) {
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
}
else { next; }
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[29] >= $DBE[30]) { debug(&quot;overmax...next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me... Next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. Next&quot;); next; }
if ($DBE[23] < 250) { debug(&quot;Not top active.. Next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
debug(&quot;Got urls&quot;);
$viv=0;
for ($qqq=0; $qqq<$urlcnt; $qqq++) {
@tmp = split(/\|/, $URLZ[$qqq]);
if ($tmp[1] eq $thecat) {
$newURLZ[$viv] = $tmp[0];
$viv++;
}
}
$newcnt = @newURLZ;
if ($newcnt < 1) { debug(&quot;No URLs this category&quot;); next; }
$url = $newURLZ[int(rand($newcnt))];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if ($user eq &quot;KDK&quot;) { &toplasttry; }
}

sub toplasttry {
debug(&quot;TA last Try&quot;);
srand;
opendir(DATA, &quot;$config[7]&quot;);
$tot = @DB = readdir(DATA);
closedir (DATA);
$numba = int(rand($tot));
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
if (-e &quot;$config[7]/$DB[$jjj]&quot;) {
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
}
else { next; }
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[29] >= $DBE[30]) { debug(&quot;overmax...next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me.. next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. Next&quot;); next; }
if ($DBE[23] < 250) { debug(&quot;Not top active.. Next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
$url = $URLZ[int(rand($urlcnt))];
@tmp = split(/\|/, $url);
$url = $tmp[0];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if (($user eq &quot;KDK&quot;) && ($checkedpriority eq &quot;0&quot;)) { &priorityuser; }
}

sub reguser {
debug(&quot;Reg User&quot;);
$checkedreg = &quot;1&quot;;
srand;
$tot = @DB = getfile(&quot;./categories/$thecat&quot;);
debug(&quot;The Cat:$thecat&quot;);
$numba = int(rand($tot));
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
if (-e &quot;$config[7]/$DB[$jjj]&quot;) {
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
}
else { next; }
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[29] >= $DBE[30]) { debug(&quot;overmax...next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me... Next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. Next&quot;); next; }
if ($DBE[23] < $activemin) { debug(&quot;Not active.. Next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
debug(&quot;Got urls&quot;);
$viv=0;
for ($qqq=0; $qqq<$urlcnt; $qqq++) {
@tmp = split(/\|/, $URLZ[$qqq]);
if ($tmp[1] eq $thecat) {
$newURLZ[$viv] = $tmp[0];
$viv++;
}
}
$newcnt = @newURLZ;
if ($newcnt < 1) { debug(&quot;No URLs this category&quot;); next; }
$url = $newURLZ[int(rand($newcnt))];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if ($user eq &quot;KDK&quot;) { &lasttry; }
}
sub lasttry {
debug(&quot;Last Try&quot;);
srand;
opendir(DATA, &quot;$config[7]&quot;);
$tot = @DB = readdir(DATA);
closedir (DATA);
$numba = int(rand($tot));
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
if (-e &quot;$config[7]/$DB[$jjj]&quot;) {
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
}
else { next; }
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[29] >= $DBE[30]) { debug(&quot;overmax...next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me.. next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. Next&quot;); next; }
if ($DBE[23] < $activemin) { debug(&quot;Not active.. Next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
$url = $URLZ[int(rand($urlcnt))];
@tmp = split(/\|/, $url);
$url = $tmp[0];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if (($user eq &quot;KDK&quot;) && ($checkedpriority eq &quot;0&quot;)) { &priorityuser; }
}
sub priorityuser {
debug(&quot;Priority User&quot;);
srand;
$tot = @DB = getfile(&quot;highpriority.txt&quot;);
$numba = int(rand($tot));
debug(&quot;Total: $tot Numba: $numba&quot;);
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[29] >= $DBE[30]) { debug(&quot;overmax...next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me.. next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. Next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
$viv=0;
for ($qqq=0; $qqq<$urlcnt; $qqq++) {
@tmp = split(/\|/, $URLZ[$qqq]);
if ($tmp[1] eq $thecat) {
$newURLZ[$viv] = $tmp[0];
$viv++;
}
}
$newcnt = @newURLZ;
if ($newcnt < 1) { debug(&quot;No urls in cat&quot;); next; }
$url = $newURLZ[int(rand($newcnt))];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if ($user eq &quot;KDK&quot;) { &prioritylasttry; }
}
sub prioritylasttry {
debug(&quot;Priority Last Try&quot;);
srand;
$tot = @DB = getfile(&quot;highpriority.txt&quot;);
$numba = int(rand($tot));
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-z]/) { next; }
debug(&quot;Checking: $DB[$jjj]&quot;);
if (-e &quot;$config[7]/$DB[$jjj]&quot;) {
@DBE = getfile(&quot;$config[7]/$DB[$jjj]&quot;);
}
else { next; }
if ($DBE[18] eq &quot;yes&quot;) { debug(&quot;Paused.. Next&quot;); next; }
if ($DBE[0] eq $username) { debug(&quot;Its me.. next&quot;); next; }
if ($DBE[3] - $DBE[4] < 12) { debug(&quot;Not enough credits.. next&quot;); next; }
$urlcnt = @URLZ = getfile(&quot;$config[7]/$DB[$jjj].list&quot;);
debug(&quot;Getting URLs&quot;);
$url = $URLZ[int(rand($urlcnt))];
@tmp = split(/\|/, $url);
$url = $tmp[0];
$user = $DB[$jjj];
debug(&quot;FOUND--$user $url&quot;);
last;
}
if (($user eq &quot;KDK&quot;) && ($checkedreg eq &quot;0&quot;)) { &reguser; }
}
sub debug {
local($message) = @_;
if ($username eq &quot;robertbug&quot;) { print &quot;$message<BR>&quot;; }
}
if ($user eq &quot;KDK&quot;) { $url = $config[2]; }

print<<d00der;
<HTML>
<HEAD>
<SCRIPT type=&quot;text/javascript&quot;>
<!--
if (top.location != self.location) {
top.location = self.location
}

var r=Math.random()
if (r>0.98)
{
alert(&quot;ROBOSTOPPER BOX&quot;)
}

</SCRIPT>
<TITLE>$config[0]</TITLE>
</HEAD>
<FRAMESET ROWS=&quot;$config[5],100%&quot; FRAMESPACING=&quot;0&quot; BORDER=&quot;0&quot;>
<FRAME MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot; NAME=&quot;$frm3&quot; NORESIZE SCROLLING=NO SRC=&quot;count.cgi?u=$username&o=$user&a=bot&quot; FRAMEBORDER=&quot;0&quot;>
<FRAME MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot; NAME=&quot;$frm2&quot; SCROLLING=AUTO SRC=&quot;$url&quot; FRAMEBORDER=&quot;0&quot;>
<NOFRAMES>
<BODY>
<P>
This page is designed for use with a browser that supports frames.
</BODY>
</NOFRAMES>
</FRAMESET>
</HTML>
d00der
exit;


#############################################################################
#############################################################################
## ##
## ________ __ _ __ __ ##
## / _______| | | |_| \ \ / / ##
## | | | | _ \ \ / / ##
## | | | | | | \ \/ / ##
## | | | | | | / /\ \ ##
## | |______ | |_____ | | / / \ \ ##
## \________| \_______| |_| /_/ \_\ ##
## ##
## Script by CLiX ##
#############################################################################
#############################################################################
## CLiX CGI Library Version CSBX2.0 ##
## Created 7/12/01 Created by CLiX ##
## CopyRight © 2001 CLiX clix@clixscripts.cjb.net ##
## Get other scripts at: theclixnetwork.com ##
#############################################################################
#############################################################################
## CLiX CGI Library can be used for personal and commercial use ONLY if ##
## this header is left in here. Also please email me ( or use the form ##
## on my site ) telling me your address. This is so I can see how my ##
## scripts are used. Use these scripts at your own risk. Im not ##
## responsible for anything this script does. ##
#############################################################################
#############################################################################
## Variables ##
## Set this to a banner code (if on a free host site)
$Freead = &quot;<!--VirtualAvenueBanner-->&quot;;
## This is wether or not to use flock (1-yes,0-no)
$flock = &quot;0&quot;;
## Number of days before a cookie expires
$exp = &quot;21&quot;;
## Path To Sendmail
$sema = &quot;/usr/sbin/sendmail -t&quot;;
## Do Not Edit Below ##
#############################################################################
#############################################################################
## THIS VERSION SPECIALLY MODIFIED FOR CSBX ##
$PH = &quot;no&quot;;
sub getinput {
$meth = $ENV{'REQUEST_METHOD'};
if (!defined $meth || $meth eq '') {
$temp = &quot;$ENV{'QUERY_STRING'}&quot;;
}
elsif ($meth eq &quot;POST&quot;){
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
}
elsif ($meth eq &quot;GET&quot;) {
$temp = &quot;$ENV{'QUERY_STRING'}&quot;;
}
else {
dienice(&quot;Unknown method: $meth&quot;);
}
@pairs=split(/&/,$temp);
$in{ip} = &quot;$ENV{'REMOTE_ADDR'}&quot;;
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack(&quot;c&quot;,hex($1))/ge;
chomp($content);
$in{$key}=$content;
if ($key =~ /URL/) {
$key =~ s/URL-//;
$inurl[$key] = $content;
}
if ($key =~ /SEL-/) {
$key =~ s/SEL-//;
$incat[$key] = $content;
}
}
}

sub sendmail {
local($to,$from,$subject,$message) = @_;

open (MESSAGE,&quot;|$sema&quot;);
print MESSAGE &quot;To: $to\n&quot;;
print MESSAGE &quot;From: $from\n&quot;;
print MESSAGE &quot;Subject: $subject\n\n&quot;;
print MESSAGE &quot;$message\n\n&quot;;
close (MESSAGE);

}

sub dienice {
my($msg) = @_;
&printhead;
print &quot;$Freead<P>\n&quot;;
print &quot;<h2>Error</h2><BR><HR><BR>\n&quot;;
print $msg;
exit;
}

sub getfile {
local($filename) = @_;
open(FILE, &quot;$filename&quot;) or dienice(&quot;Couldnt open $filename: $!&quot;);
if ($flock eq &quot;1&quot;) { flock(FILE, 2); }
@data = <FILE>;
close FILE;
$num = @data;
for ($i=0; $i<$num; $i++) {
chomp($data[$i]);
}
return @data;
}


sub appfile {
local($filename, @text) = @_;
open(FILE, &quot;>>$filename&quot;) or dienice(&quot;Couldnt append to $filename: $!&quot;);
if ($flock eq &quot;1&quot;) { flock(FILE, 2); }
foreach $text(@text) {
print FILE &quot;$text\n&quot;;
}
close FILE;
}

sub writefile {
local($filename, @text) = @_;

open(FILE, &quot;>$filename&quot;) or dienice(&quot;Couldnt write to $filename: $!&quot;);
if ($flock eq &quot;1&quot;) { flock(FILE, 2); }
foreach $text(@text){
print FILE &quot;$text\n&quot;;
}

close (FILE);
}

sub printhead {
if ($PH ne &quot;y&quot;) {
print &quot;Content-type: text/html\n\n&quot;;
$PH = &quot;y&quot;;
}
}

##
## sub getcookies
## Gets cookies and stores in %cookie
##

sub getcookies {
if ($ENV{'HTTP_COOKIE'}) {
foreach (split(/; /,$ENV{'HTTP_COOKIE'})){
($cookie,$value) = split(/=/);
$Cookies{$cookie} = $value;
}
}
}

##
## sub makecookies
## usage:
## makecookies(&quot;name1&quot;,&quot;value1&quot;,&quot;name2&quot;,&quot;value2&quot;)
## $exp is the number of days untill expiring (set in variables at top)
sub makecookies {
local(@cookies) = @_;
$expdate = mygmttime(time + (86400*$exp));
while( ($cookie,$value) = @cookies ) {
print &quot;Set-Cookie: $cookie=$value; expires=$expdate \n&quot;;
shift(@cookies); shift(@cookies);
}
}

sub cryptor {
local ($field, $pw) = @_;
$field = crypt($field,substr($pw,0,2));
return $field;
}

$der = &quot;der&quot;;

1;

also when i added the -w to the first line of the start script the premature error went away
 
also another thing its not doing is it says the file does
not exits when it goes to get it
 
print<<d00der;
Robert, try outputting the Content type after this line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top