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

Im getting the following errors
[Sun Mar 12 21:19:27 2006] [error] [client 127.0.0.1] File does not ex +ist: /Library/WebServer/Documents/favicon.ico [Sun Mar 12 21:19:27 2006] [error] (8)Exec format error: exec of /Libr +ary/WebServer/CGI-Executables/first.pl failed [Sun Mar 12 21:19:27 2006] [error] [client 127.0.0.1] Premature end of + script headers: /Library/WebServer/CGI-Executables/first.pl

what do they mean
My shebang line is correct

[lupercal:/library/webserver/cgi-executables] richill% whereis perl /usr/bin/perl

My code is saved as a unix file

#!/usr/bin/perl print "Content-type: text/html\r\n\r\n"; print "Hello, World.";

I can send httpd.config file if it will help

20060313 Janitored by Corion: Added formatting

Replies are listed 'Best First'.
Re: How can i run perl on osx
by graff (Chancellor) on Mar 12, 2006 at 23:48 UTC
    I just tried that on my own macosx (10.4.5 with perl 5.8.6), and the apache server had no problem with it at all (I got "Hello, Word" in the browser).

    I've never seen "Exec format error" before, though there do seem to be a number of references you can find if you google that string. Does /usr/bin/perl work for you from the command line? (And does that script work from the command line, if you just type /Library/WebServer/CGI-Executables/first.pl at the shell prompt?) Based on the few google hits I've looked at for this error message, I would expect the command line usage to fail just like the web-server usage.

    Are you sure that the shebang line ends with just a line-feed (LF, 0x0a), rather than anything involveing a carriage-return (CR, 0x0d)? (Check it using the "od" command; also try changing it to  #!/usr/bin/perl -T)

    I doubt that httpd.config has anything to do with it (I don't think anyone here wants to review that), but you should probably check it over on your own.

Re: How can i run perl on osx
by jhourcle (Prior) on Mar 13, 2006 at 20:41 UTC
    A few suggestions --

    Either ignore the message about 'favicon.ico', or touch that file in your root directory -- it's a web browser trying to request a 'Favorites Icon', so it'll show a little 16x16 image in your location bar. Any internet search for 'favicon.ico' should bring up some info on how to create one, if you want to go that route.

    By your comment 'my code is saved as a unix file', I'm going to assume that it wasn't created on a unix system, or that you're using an editor like BBEdit that makes a distinction on what line endings and/or content encoding it uses. Whatever the case, change the shebang line to include '--' as it'll reduce the chance of DOS line endings from screwing up your files.

    And, make sure you've set the proper permissions on the file:

    chmod o+rx /Library/WebServer/CGI-Executables/first.pl
      Thank you graff and jhourcle. I checked the shebang line again and it was wrong. There was a hidden character at the start. Thank you again.