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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Premature end of scripture headers..

Status
Not open for further replies.

JulioSanchez

Programmer
Joined
Jun 14, 2001
Messages
1
Location
CA
Hi, I am writing a little perl script here, and I am having a heck of a time figuring out this one error. Whenever I run the script I recieve a premature end of scripture headers error. I've tried manipulating the http headers returned in a number of ways, but I can't seem to get anything to work, and I believe there is something fundamentally wrong with my code. Any assistance would be greatly appreciated, and thanks ahead of time....

here's the code...
____________________________________________________ _ _ _ _

#!/usr/local/bin/perl -w
use English;
use diagnostics;
use strict;

#BEGIN
# {
# open STDERR, ">&STDOUT";
# print &quot;Content-type: text/html\n\n<PRE>&quot;;
# }

$| = 1; #this clears out the stdout

my (%inputo); #this declares the hash where the input will go
my (@files);
my ($rfile);
my ($year);
my ($month);
my ($day);
my (@lines);
my ($gillam600);
my ($gillam700);
my ($gillam800);
my ($eureka600);
my ($eureka700);
my ($eureka800);


getInputo (\%insub getInputo

{
my ($hashRef) = shift; #initialize the variable to hold the hash
reference
my ($buffer) = &quot;&quot;; #initialize the buffer to hold info

read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #reads in the form
info

foreach (split(/&/, $buffer)) #goes through the whole buffer
where the input is stored
{
my ($key, $value) = split(/=/, $_); #splits up the input
into the date and value
$key = decode($key); #sets the key and value to the
decoded values
$value = decode($value);
$hashRef->{$key} = $value; #sets the key and value in the
hash table
}
}

sub decode
{
$_ = shift; #the decode function which gets rid of all the stars
which represent spaces
tr/+/ /;
s/%(..)/pack('c', hex($1))/eg; #convert any symbols out of hex
back to symbols
return($_);
}

sub mainer

{

opendir (DIR, &quot;~/datas/&quot;); #open the directory where all
the text files are
@files = sort(grep (/txt$/, readdir(DIR))); #finds all
the text files in the directory
closedir (DIR);

foreach (@files)
{
$rfile = grep (/$year-$month-$day/, $_); #find
the file whos title matches the date
}

if ( ! $rfile )
{
return ($eureka600, $eureka700,
$eureka800, $gillam600, $gillam700, $gillam800);
}


open (FILE, $rfile);
@lines= <FILE>; #read in the desired file
close FILE;


foreach (@lines)
{
$eureka600= grep(/eureka600/, $_); #these loops
search through the
#file to see if
the given strings are
#present
}

foreach (@lines)
{
$eureka700 = grep(/eureka700/, $_);
}

foreach (@lines)
{
$eureka800= grep(/eureka800/, $_);
}
foreach (@lines)
{
$gillam600= grep(/gillam600/, $_);
}

foreach (@lines)
{
$gillam700= grep(/gillam700/, $_);
}

foreach (@lines)
{
$gillam800= grep(/gillam800/, $_);
}


return ($eureka600, $eureka700, $eureka800, $gillam600,
$gillam700, $gillam800);
#returns the variables back to the javascript
program..

print &quot;Location: ~/public_html/data1.html\n\n&quot;; #the document we
want the info passed to
print &quot;Window-target: sites\n\n&quot;; #the frame where we want the
html doc to appear
}
_______________________________________________ _ _ _


 
um, i didn't really look at the code, but the header seems like it's missing the &quot;Content-type: text/html\n\n&quot; part, which i'm pretty sure is necessary for it to work; well, some sort of content-type is necessary, doesn't have to be text/html.

also, just to check, run this on the command line:[tt]
perl -cw script.pl
[/tt]
just to make sure it's not due to an error in the code...

HTH &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top