Perl CGI returning plain text HTML code

Discussion in 'Perl Misc' started by ich_bin_Ingenieur, Mar 23, 2007.

  1. 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?
    ich_bin_Ingenieur, Mar 23, 2007
    #1
    1. Advertising

  2. ich_bin_Ingenieur wrote:
    > 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
    Jürgen Exner, Mar 23, 2007
    #2
    1. Advertising

  3. ich_bin_Ingenieur

    Brian Wakem Guest

    ich_bin_Ingenieur wrote:

    > 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.


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Wakem, Mar 23, 2007
    #3
  4. ich_bin_Ingenieur <> wrote:
    > 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
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Mar 23, 2007
    #4
  5. ich_bin_Ingenieur

    Guest

    On Mar 23, 2:19 am, Brian Wakem <> wrote:
    > ich_bin_Ingenieur wrote:
    > > 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.


    Actually... Even if the correct PLAINTEXT header is printed IE will
    still attempt to read any HTML in that file.
    , Mar 27, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. greg

    web form returning text/plain ?

    greg, Aug 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    404
    Raghavendra T V
    Aug 27, 2004
  2. A
    Replies:
    0
    Views:
    272
  3. BMA TRADING

    Re: CGI script is in plain text

    BMA TRADING, Jul 4, 2003, in forum: Python
    Replies:
    1
    Views:
    492
    Alan Kennedy
    Jul 4, 2003
  4. robert112
    Replies:
    1
    Views:
    2,784
    Sowmya J
    Jan 21, 2010
  5. Jake Barnes
    Replies:
    9
    Views:
    751
    dave cutts
    Feb 21, 2006
Loading...

Share This Page