Hi guys,

Need help in solving the following problem :

I have an apache web server running with perl 5.8.4 on a Linux Redhat 9.0 box. In the cgi-bin folder, i have this file test.pl with the following content :
#!/usr/local/bin/perl print "Content-type: text/html\n\n"; print "<H1>Hello World</H1>\n";
Just a simple script to help illustrate the problem I'm facing.

When I run this from the browser, it returns an INTERNAL SERVER PROBLEM. Log from apache shows "Premature end of script headers: test.pl".

Now... I have searched thru this site and other PERL sites, and gone thru all the steps the others have suggested, but still things didn't help.

The following are some further testing done by me :

- If I run the script directly using "./test.pl", it gives me the following result :
[root@www cgi-bin]# ./test.pl : bad interpreter: No such file or directory


- If I run the script using "perl test.pl", it gives me the correct output :
[root@www cgi-bin]# perl test.pl Content-type: text/html <H1>Hello World</H1>
I checked the path of PERL and that's correctly entered. So couldn't be any path issues.

- If I edit the script to add in a "-w" after the "perl" at the first line, everything runs fine, even from the browser. Here's the updated script :
#!/usr/local/bin/perl -w print "Content-type: text/html\n\n"; print "<H1>Hello World</H1>\n";
Is there anything that I have not done correctly? Why is it that I require a "-w" in this server, while not in any of the rest of my apache servers with PERL??

Anybody can shed some light into me?

In reply to bad interpreter: No such file or directory by beng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.