COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button
C++ LANGUAGE FIRST CGI PROGRAM
First CGI Program
Consider the following C++ Program content:
#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;
}
Compile above code and name the executable as cplusplus.cgi.
This file is being kept in /var/www/cgi-bin directory and it
has following content. Before running your CGI program make
sure you have change mode of file using chmod 755 cplusplus.
cgi UNIX command to make file executable. Now if you click
cplusplus.cgi then this produces the following output:
No comments:
Post a Comment