George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:

I keep getting an error with a whole load of CGIs. For a long time I assumed it was because of something dim that I'm doing. But I'm beginning to think it's my ISP. So I put a very simple script up and... it falls over. Can you tell me whether I'm completely mad? This shouldn't fall over, should it?
#!usr/bin/perl -w use strict; use CGI qw(:standard); print header; print "hello world";
But it does, as you can see here. File permissions are 755. The error log says
[Fri Oct 12 01:00:49 2001] [error] [client 62.253.128.5] Premature end + of script headers: /home/htdocs/hosted/thinweb/trainingboard.co.uk/p +roviders/test.pl fopen: Permission denied failed to open log file
Tell me I'm crazy! Or tell me I'm not crazy but there's something awfwy squoowy going on awound my ISP. Or even better... tell me what this fopen nonsense is all about. Sorry if this post sounds a bit confused - I've been struggling with this too long. I'm off to put my head in a bucket of water now. And me with this terrible pains in all the diodes down my left side.

§ George Sherston

Replies are listed 'Best First'.
Re: There isn't anything wrong with this, is there?
by VSarkiss (Monsignor) on Oct 12, 2001 at 04:24 UTC

    If this is an accurate copy-and-paste, your shebang line is broken: you left out the slash before "usr". Unless the interpreter really is in usr/bin/perl under the cgi directory.

    Can I call you crazy anyway? ;-)

    HTH

      This makes sense, since George was testing on Win32. He probably has his server set to associate files with Perl based on a .pl extension or something, as opposed to the #! line.
Re: There isn't anything wrong with this, is there?
by thatguy (Parson) on Oct 12, 2001 at 04:26 UTC
    it worked ok on my box once i changed the ! to / in the shebang :)

    i think that your ISP may have the logfile permissions wrong or worse. definately give them a call.
    -p

Re: There isn't anything wrong with this, is there?
by George_Sherston (Vicar) on Oct 12, 2001 at 05:10 UTC
    /me tears hair. The shebang line was wrong. I have to get myself some colleagues... but at least I have sibling monks. Actually I only tear out half of my hair, because I think that even with a broken shebang line, it shouldn't give THAT error? Should it? Tell me I'm only half crazy?

    § George Sherston
      I take it you are developing on win32. On Unix, which is probably your ISP's platform OS, a bungled shebang will definitely result in a fatal error. The shebang line tells the shell to run the text following using the program named in it. If that path is broken, your script is broken.

      Update:

      The result of running the script is "Premature end of script headers". This is the error that webservers typically return whenever a CGI script dies before it can output valid HTML headers, which is exactly what is happening in this case. You have already done this, so you know, but for anyone else reading this who might have a similar problem, the next step is to run the script on the command line *on the same platform*. Then you'll see another slightly cryptic message such as "ksh: {scriptname}: not found". Typos in shebangs trip up everyone from time to time. ;)
        Right on both counts. My question, though, is whether I would expect to get the mystery log file error as a result of a broken shebang line. It doesn't make sense to this bear of little brain. I would have expected something like interpreter not found or no such file... not
        fopen: Permission denied failed to open log file
        which is what I actually get. But it's perfectly possible I'm mistaken as this is definitely not my area of expertise. If anyone can tell me, I'd be very grateful.

        § George Sherston
      "Actually I only tear out half of my hair"

      If you did, I hope it was in the shape of a circle on the top of your head - then you'd look like a monk ;-)

      cLive ;-)

      I think the shbang problem would produce that error -- it was trying to open a non-existing program ( "some_dir/usr/bin/perl" ) to execute, and hence the error about fopen failing and not having permission ( no permission because the fopen failed )

      just guessing here, though...