PDA

View Full Version : Execute C program from CGI script


rpadalia
01-20-2007, 11:30 AM
Hi List.
My cgi script developed in C works fine. I want to execute other C program through this script. How do I do that?
Here is the script that works. Now I want to uncomment line //execlp..........and excute this program. However by doing so, I get error 500 on browser. The c complied program "/var/www/html/webrelay_cgi" is not cgi script and works fine when executes from command line. Any help will be appreciated.
---------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

main()
{
printf("Content-type: text/html\n\n");
printf("<HTML>\n");
printf("<BODY>\n");
printf("<H1>HELLO WORLD!</H1>\n");
printf("</BODY>\n");
printf("</HTML>\n");
//execl("/var/www/html/webrelay_cgi", "on", NULL);
}