0

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.

3
  • 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/… Commented 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. Commented 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. Commented Mar 24, 2015 at 19:05

1 Answer 1

1

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;
}
Sign up to request clarification or add additional context in comments.

4 Comments

Can u explain me stepwise. The action of the form, the cgi-bin folder etc. How do i configure those settings.
There is nice article that will help you get started: garshol.priv.no/download/text/http-tut.html
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?
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.