|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
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).] |
|
#2
|
|||
|
|||
|
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; |
|
#3
|
|||
|
|||
|
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 . |
|
#4
|
|||
|
|||
|
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? |
|
#5
|
|||
|
|||
|
<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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Premature end of scriptheaders |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|