Perl CGI returning plain text HTML code

I

ich_bin_Ingenieur

So it's like this...

I wrote a PERL script that receives GET data and returns a webpage,
and this script works fine when used with Internet Explorer on a PC...

But when running this script on Mozilla, Opera, or Safari on a MAC, it
returns the a plain text file in the browser window of the HTML code,
rather than displaying the HTML page.

I'm not sure what's causing it to act like this. I've tested numerous
PHP CGI's in the same browsers and they all work correctly.

The script has been CHMODed to 755, it has a .cgi extention, and it
returns an HTML page with the meta header <meta http-equiv="Content-
Type" content="text/html; charset=iso-8859-1">. I've tried changing
the permission, changing the extention, and I'm trying to see if I can
Google this problem, but no luck yet.

The first part of the webpage is returned using a "print <<ENDHTML;"
block, and the rest of the page is returned through print
statements.

Has anyone heard about this behavior? Does anyone know what the
problem might be?
 
J

Jürgen Exner

ich_bin_Ingenieur said:
So it's like this...
[Subject: Perl CGI returning plain text HTML code]

Well, yeah, that is what any CGI program is supposed to do (assuming you
want to return HTML).

I wrote a PERL script that receives GET data and returns a webpage,
and this script works fine when used with Internet Explorer on a PC...

But when running this script on Mozilla, Opera, or Safari on a MAC, it
returns the a plain text file in the browser window of the HTML code,
rather than displaying the HTML page.

Why do you think, this has anything, anything at all to do with Perl?

jue
 
B

Brian Wakem

ich_bin_Ingenieur said:
So it's like this...

I wrote a PERL script that receives GET data and returns a webpage,
and this script works fine when used with Internet Explorer on a PC...

But when running this script on Mozilla, Opera, or Safari on a MAC, it
returns the a plain text file in the browser window of the HTML code,
rather than displaying the HTML page.


You are not printing the correct header.

IE incorrectly tries to determine file type from the contents even after
you've printed a text/plain header. IE is broken and so is your script.

If you can't work it out then post the part of your script that prints the
header.
 
J

Jens Thoms Toerring

ich_bin_Ingenieur said:
I wrote a PERL script that receives GET data and returns a webpage,
and this script works fine when used with Internet Explorer on a PC...
But when running this script on Mozilla, Opera, or Safari on a MAC, it
returns the a plain text file in the browser window of the HTML code,
rather than displaying the HTML page.
I'm not sure what's causing it to act like this. I've tested numerous
PHP CGI's in the same browsers and they all work correctly.

Sorry, but CGI scripts aren't "run" by a browser - the browser just
renders what a _web server_ sends it and the _web server_ invokes
the CGI script, reading its output and passing that on to the client,
i.e. the browser.
The script has been CHMODed to 755, it has a .cgi extention, and it
returns an HTML page with the meta header <meta http-equiv="Content-
Type" content="text/html; charset=iso-8859-1">. I've tried changing
the permission, changing the extention, and I'm trying to see if I can
Google this problem, but no luck yet.

Hard to say without any real information, but my best guess at the
moment is that the output of your script isn't HTML (a <meta...>
line alone somewhere in the text isn't enough) and the Internet
Exploder treats it for some strange reason as HTML anyway while
the more standard conforming browsers don't. Can one have a look
at the output of your script and/or what exactly arrives at the
browser?
Regards, Jens
 
K

krakle

You are not printing the correct header.

IE incorrectly tries to determine file type from the contents even after
you've printed a text/plain header. IE is broken and so is your script.

Actually... Even if the correct PLAINTEXT header is printed IE will
still attempt to read any HTML in that file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top