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

Dear monks,

i wrote a html file in /var/www/cgi-bin....
i am repeatedly getin "exec format error" even after changing the file permissions to "777"
any clue as to why this is happening

thanks®ards
lax

2006-07-04 Retitled by Corion, as per Monastery guidelines
Original title: 'CGI'

Replies are listed 'Best First'.
Re: exec format error with CGI program
by davorg (Chancellor) on Jul 04, 2006 at 08:36 UTC
    i wrote a html file in /var/www/cgi-bin....

    You probably don't want to do that :-)

    Your web server is probably configured to execute any files served from your cgi-bin directory. That makes sense as that's what the cgi-bin directory is for.

    Therefore, any time your web server gets a request for a file in your cgi-bin directory, it tries to execute that file and return the output to the user.

    An HTML file is not an executable program. Therefore the web server can't execute it and your operating system generates the error that you see.

    The solution is to put cgi programs in the cgi-bin directory and static HTML files in the htdocs directory (or whatever the equivalent is in your configuration).

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      hi

      thanks , your solution worked,i put the html file in the html folder and its workin now

      thanks
      lax
      If it's the same as any other ISP, then they'll very likely be running any scripts within the cgi-bin directory using suEXEC. This means that the script needs to have 755 permissions set. Any other combination will cause it to fail. See this link for more details of my ISP.....

        Firstly, we don't know that there's an ISP involved at all. This sounds like a standard Apache installation which could be on the original poster's own Linux server (for example). The default Apache installation doesn't use suexec. So why complicate things unnecessarily.

        Secondly, the problem (and the solution) had absolutely nothing to do with programs or permissions. It was simply that the original poster had a static HTML file in his cgi-bin directory.

        --
        <http://dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re: exec format error with CGI program
by Corion (Patriarch) on Jul 04, 2006 at 08:33 UTC

    Please show us the minimal Perl code of your CGI program. Most likely, your webserver error log has more information, but without a minimal script that reproduces your problem, it's hard to tell.

    How (Not) To Ask A Question has lots of good information on how to ask your questions more effectively.

Re: exec format error with CGI program
by Nevtlathiel (Friar) on Jul 04, 2006 at 08:45 UTC
    even after changing the file permissions to "777"

    I'm sure it's just for testing but that's really not a good idea - it means anyone can read, write or execute your file which is probably not what you really want. Try 755 (other people can read and execute, but not write), or maybe something even more restrictive.

    ----------
    My cow-orkers were talking in punctuation the other day. What disturbed me most was that I understood it.

Re: CGI
by jeanluca (Deacon) on Jul 04, 2006 at 08:40 UTC
    You're description is too brief! so more info is absolutely needed. But my guess would be that it has todo with your httpd.conf file, maybe you've added .html to AddHandler cgi-script

    LuCa

      Given that the original poster said "i wrote a html file in /var/www/cgi-bin", theres no need to add .html to the cgi-script handler to get this behaviour. The default ScriptAlias setting will explain the problem.

      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg