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

Prem. end of script headers error...

Status
Not open for further replies.

ryen

Programmer
Jul 29, 2002
22
US
Hi all,
I just installed linux the other day (i've never used it before) and I managed to get apache going alright, except when it comes to this one PERL script.

see, i have a dual boot system. from linux, i copied an old perl script from a folder from my windows partition to my cgi-bin. i set the chmod to 777, and tried running it from a separate box. It gave me the following error:
(2)No such file or directory: exec of /var/ failed
Premature end of script headers: /var/
It was a pretty simple script, but i used vi editor to cut all the text out and simply print "hello" to the browser. It still gives me the error. I then tried making an identical file from scratch in linux, and it works fine. I think it has to do with the actual file TYPE, as in a DOS file, perhaps (?) I noticed that when i edited the file in VI, it said [dos] at the bottom...

does anyone know how to remedy the problem?
any help would be appreciated.
-ryen
 
"Premature end of script headers" = did not do below code...
Code:
print "Content-type: text/html\n\n";
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
mmmm.... "Premature End of Script headers" can mean almost
anything. Make this your program: (change the first line to reflect your path/to/perl


#!/usr/bin/perl

use CGI;
use CGI::Carp qw/fatalsToBrowser/;

my $j = new CGI;

print $j->header();

print "Hello, World...";

If this doesn't work then it's not your script, it maybe .

--jim
 
hmmm... honestly i don't think that's the problem.
I think it has to do with the file coming from a DOS/Windows partition.. perhaps when i copied it from that partition to the Linux partition, it copied it in Binary mode or something like that. The reason I think this is the case is because I re-created the file character-for-character from linux, and that version worked perfectly. I appreciate the input, I'll fiddle around and see what I can do. Thanks again.
 
open the file from the command line like so:
vi -b file.cgi

If you see a lot of ^M then you need to get rid of them. *nix machines use newlines (\n in perl) for line deliminators and windows uses carriage return linefeeds (\n\r in perl or is it the other way around). So you can do something like this from the command line
perl -pi '.bak' -e 's/\r//g' file.cgi
to get rid of them.

Hope This Helps,
Johnny
 
You can also use 'dos2unix' to convert the dos file into a *nix file.

dos2unix dos_file.pl >new_file_name.pl -enter-

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top