The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Premature end of scriptheaders
Discuss Premature end of scriptheaders in the Perl Programming forum on Dev Shed. Premature end of scriptheaders Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 3rd, 2000, 03:42 AM
|
|
Contributing User
|
|
Join Date: May 2000
Location: Alkmaar, The Netherlands
Posts: 123
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
Hi all,
I'm trying to write a Perl 5.005_03 script that returns a HTTP-header and prints something like Hello World. When I execute it on Red Hat Linux 6.1 it gives the output that I expect. However when I request that page in MSIE 4 on a different machine I get a 500 Internal Server Error. When I check the apache 1.3.9 logs on my Linux machine it first says "no such file or directory" and the second entry says premature end of script-headers.
Can anybody help me?
I checked the Perl path and priveledges on the file, they are okay.
The code looks something like this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#! /usr/bin/perl
my $sessiondid="";
my ($name,$value)=split(/=/,$ENV{'QUERY_STRING'});
$value=~tr/+/ /;
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$name=~tr/+/ /;
$name=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
if ($name="session-id") {
$sessionid=$value;
}
open(INFILE,"</home/codes") or die;
$i=0;
@validSessionIds=();
while (<INFILE> ) {
@validSessionIds[$1]=substr($_,0,12);
$i++;
}
close(INFILE);
my $validation = 0;
foreach $x (@validSessionIds) {
if ($x eq $sessionid) {
$validation=1;
}
}
if ($validation) {
print "Set-Cookie: check=truen";
print "Status: 302 Movedn";
print "Location: <A HREF="http://somewhere.comn";" TARGET=_blank>http://somewhere.comn";</A>
print "Content-Type: text/htmlnn";
print "<HTML><HEAD></HEAD><BODYn";
print "Halleluja!n";
print "</BODY></HTML>n";
}
else {
print "Status: 302 Movedn";
print "Location: <A HREF="http://somewhereelse.com/n";" TARGET=_blank>http://somewhereelse.com/n";</A>
print "Content-Type: text/htmlnn";
print "<HTML><HEAD></HEAD><BODY>n";
print "Ohhh Noooo, You failed!n";
print "</BODY></HTML>n";
}
[/code]
It will retrieve a session-id from the query-string and compare it with some session-id's in a file. If the check succeeds you get a cookie and are redirected to one site. If the check fails you are redirected to some other site containing an error.
Thanks for your help,
Bas
[This message has been edited by MeijdenB (edited August 03, 2000).]
|

August 3rd, 2000, 04:57 AM
|
|
Contributing User
|
|
Join Date: Jul 1999
Posts: 33
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
I suggest you try programming with the -w option after your #!/usr/bin/perl.
So #!/usr/bin/perl -w... this will give you more warnings etc.
Maybe try programming with strict on as well: use strict;
|

August 3rd, 2000, 04:33 PM
|
|
Contributing User
|
|
Join Date: Aug 2000
Location: Indiana
Posts: 614
  
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 14
|
|
all use strict; does is causes all kinds or problems if you don't define a variable before it tries to get used... that's not what's causing your problem.
As far as your problem goes, I don't know what to tell you. I'd try out the script, but my server's in crash mode today and I Apache refuses to restart, so F it  .
|

August 3rd, 2000, 05:10 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
What are you trying to do with this...
open(INFILE,"</home/codes") or die;
$i=0;
@validSessionIds=();
while (<INFILE> ) { @validSessionIds[$1]=substr($_,0,12);
$i++;
}
close(INFILE);
>>my $sessiondid="";
Perhaps a mispell?
|

August 4th, 2000, 01:19 AM
|
|
Contributing User
|
|
Join Date: May 2000
Location: Alkmaar, The Netherlands
Posts: 123
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
What are you trying to do with this...
open(INFILE,"</home/codes") or die;
$i=0;
@validSessionIds=();
while (<INFILE> ) { @validSessionIds[$1]=substr($_,0,12);
$i++;
}
close(INFILE);
>>my $sessiondid="";
Perhaps a mispell?[/quote]
This file, /home/codes, is written by a different program. It contains some session-ids. With this while-loop I try to put those session-ids in an array. Although $1 should off course be $i. Typo's do happen some time  , but that isn't the problem I guess.
Bas
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|