[RESOLVED] execve() Exec format error

Discussion in 'CGI/Perl/Python' started by Solutioned, Jan 12, 2010.

  1. Solutioned

    Solutioned New Member

    Hello, I'm surprised by the speed of execution of programs in C compared to PHP, so I decided to work with CGI programs.

    I did a "Hello, World" and compiled it on Linux, but after uploading to the server, gives me this error.

    Here is the source code.
    Code:
    #include <stdio.h>
    int main() {
    	printf("Content-Type: text/plain;charset=us-ascii\n\n");
    	printf("Hello world\n\n");
    	return 0;
    }
    
    This was compiled under an i5 processor x86-64 Debian distrubution.
    Last edited by a moderator: Jan 27, 2010
  2. mistwang

    mistwang LiteSpeed Staff

    Binary build on Debian system may not be compatible with CentOS/Redhat.
    You need to compile the binary on the same server.
  3. Solutioned

    Solutioned New Member

    Is there any way to create binaries that work for all distributions?

    Because I have a shared web hosting and have no direct access to compile. :(
  4. NiteWave

    NiteWave Administrator

    >Is there any way to create binaries that work for all distributions?

    No, clearly :)

    >Because I have a shared web hosting and have no direct access to compile

    can you try
    Code:
    gcc -o a.cgi a.c
    to create your own a.cgi. maybe most shared web hosting provide gcc nowadays?
  5. mistwang

    mistwang LiteSpeed Staff

    You have to compile the binary from a machine with matching OS like the one your hosting company uses.
  6. Solutioned

    Solutioned New Member

    Thanks to everyone, the hosting provider gave me the Shell Access and I already compile the program. :D

Share This Page