put cgi on website

Discussion in 'Computer Science & Culture' started by dreware, Mar 20, 2005.

Thread Status:
Not open for further replies.
  1. dreware Registered Member

    Messages:
    4
    I can make executables (*.exe), but i have no clue how to put it on a website without the user having to download it!
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Yamayama Registered Senior Member

    Messages:
    109
    I suspect you want to actually run a program on other people's computers. Is this correct? If so, then it's not possible unless they actually download the exectuable file (*.exe) first of all.

    If, on the other hand, you simply want to use C++ as a server-side language - similarly to how perl is used - to generate output which their browser will understand, you could code something like this:

    Code:
    #include <iostream.h>
    
    int main() {
      cout << "Content-type: text/plain\n\n";
      cout << "This is just a test\n";
      return 0;
    }
    
    (....I'm only new to C++ so there might be a better way)

    Compile this, but save it as a .cgi file - because most servers are unix; they won't deal treat .exe extensions as a binary file. Then put this file - let's say you've saved it as test.cgi - somewhere in your web-space directory. Now, presuming your web-server is configured to handle cgi-scripts, you should be able to type in http://whateveryourdomainis.com/test.cgi, and it should say:

    Code:
    This is just a test
    
    If you want to do anything complicated, it might be worth while looking into the CGILib C++ Library. Then again, you could use an interpreted language like PERL, instead of compiling your script everything you want to make a change.

    P.S. Be careful when putting CGI scripts in your web-space.
     
    Last edited: Mar 20, 2005
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. DCLXVI Bloody Bastard Registered Senior Member

    Messages:
    363
    If you compile it under windows as an exe file and try to run it on a unix webserver it's not going to work no matter how fiercely you rename it as something else.

    In order to run a cgi script on a webserver you'll need to have the daemon configured to allow cgi execution and place the file in a specified directory set aside for cgi programs, usually something like ./cgi-bin/ . Also, the format of the cgi must be compatable with the server, you won't be able to run a windows binary on a unix webserver or vice versa.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Stryder Keeper of "good" ideas. Valued Senior Member

    Messages:
    13,105
    If you are trying to get the .exe file to be executed secretly to drop a trojan on a windows system I'm not going to tell you how to do it for multiple reasons that don't need to be discussed here. (I'd suggest others don't attempt to explain either.)

    Otherwise you'd be better off explaining how you mean a bit clearer.
     
Thread Status:
Not open for further replies.

Share This Page