View Full Version : put cgi on website


dreware
03-20-05, 06:35 AM
I can make executables (*.exe), but i have no clue how to put it on a website without the user having to download it!

Yamayama
03-20-05, 07:46 AM
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:


#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:


This is just a test


If you want to do anything complicated, it might be worth while looking into the CGILib C++ Library (http://www1.las.es/~mack/developer/CGILib/CGILib.html). 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.

DCLXVI
03-20-05, 11:50 AM
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.

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.

Stryder
03-21-05, 07:19 AM
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.