I want to send inputs to my server and want server to run my c++ program.Generate the output and respond me the output to be displayed on the browser.
-
You should use CGI to do that: en.wikipedia.org/wiki/Common_Gateway_Interface Also there is ISAPI if you are on Windows platform: en.wikipedia.org/wiki/…Andrew Komiagin– Andrew Komiagin2015-03-24 18:42:58 +00:00Commented Mar 24, 2015 at 18:42
-
I am on Linux, i want it to work without any security hassle of my domain service provider as well.Kabhi– Kabhi2015-03-24 18:49:13 +00:00Commented Mar 24, 2015 at 18:49
-
Unless you know exactly what you're doing, someone will probably figure out how to exploit your program to gain sufficient access to the host to use it as a bot/gateway. Just be careful/absolutely certain this is the approach you want to take.Mark B– Mark B2015-03-24 19:05:25 +00:00Commented Mar 24, 2015 at 19:05
Add a comment
|
1 Answer
The simplest CGI app looks like this:
#include <iostream>
using namespace std;
int main ()
{
cout << "Content-type:text/html\r\n\r\n";
cout << "<html>\n";
cout << "<head>\n";
cout << "<title>Hello World - First CGI Program</title>\n";
cout << "</head>\n";
cout << "<body>\n";
cout << "<h2>Hello World! This is my first CGI program</h2>\n";
cout << "</body>\n";
cout << "</html>\n";
return 0;
}
4 Comments
Kabhi
Can u explain me stepwise. The action of the form, the cgi-bin folder etc. How do i configure those settings.
Andrew Komiagin
There is nice article that will help you get started: garshol.priv.no/download/text/http-tut.html
Kabhi
can u plz explain this tutorialspoint.com/cplusplus/cpp_web_programming.htm like whats the significance of cgi folder inside www . Should i create one cgi-bin folder and put my complied program there?
Andrew Komiagin
Once your program is uploaded to the web server, you'll want to be sure to move it to your cgi-bin (or public_html directory — wherever your ISP has told you to put your CGI programs). Then you'll also need to change the permissions on the file so that it is "executable" (or runnable) by the system. The Unix shell command for this is: chmod 755 filename