Results 1 to 4 of 4
  1. #1

    Question Perl Script - Content-type text vs html

    I have apache running on Solaris and .pl scripts are allowed to run.

    When I put the following script in the main /usr/apache/cg-bin folder, it works.

    However, there is a twist to it ! and that is: if the "content-type " is "Text" it would not display the result rather starts downloading the file but if the the "content-type" is "html" it works perfectly fine.

    Similarly, if I put the same script with content type as html in users public_html/cgi-bin folder, it does the same : start downloading the file rather than displaying the result in browser.

    I am using IE 6. I have checked all the ownership, permissions on script itself and on the folder and they are the same.

    Any clues ??

    Here is the script :

    #!/usr/bin/perl

    #hello.pl: a simple Perl CGI example

    #Note that we output two carriage returns after the
    #content type. This is very important as it marks
    #the end of the CGI "header" and the beginning of
    #the document to be sent to the browser.

    print "Content-type: text/html\n\n";
    # Output a proper HTML document, with <head>
    # and <body> tags. */

    print "<head>\n";
    print "<title>Hello, World</title>\n";
    print "</head>\n";
    print "<body>\n";
    print "<h1>Hello, World</h1>\n";
    print "</body>\n";



    Regards

  2. #2
    Join Date
    Sep 2001
    Location
    Seattle, WA
    Posts
    3,084
    What is the print line you're using for the other content-type you're using?

    If you don't specify a valid or known content-type, it will attempt to download the results as opposed to displaying them.
    Jim Reardon - jim/amusive.com

  3. #3
    Join Date
    Mar 2004
    Posts
    89
    Your browser decides whether to download or to display the page. Has nothing to do with Perl. Well, unless you are not specifying your content type correctly.

  4. #4
    Join Date
    Jun 2002
    Posts
    233
    But it is a given that the browser will display text/html-typed pages. I would say that for some reason theres a predefined MIME type in apache for .pl files that overrides what you have printed out in the script. Just a guess.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •