0

i'm trying run a cgi script from a c program using execve(). It seems to be able to open and run the cgi file. but instead of actually generating graphical html it generates html code. example: execve("this.cgi", NULL, NULL)

will generate:

/this.cgi
/this.cgi
<html>
 . . . the rest of the html code

I can't figure out why this is.

int status;
		pid_t pid;
		pid = fork();

		dup2(fileno(fp), 1);
		dup2(fileno(fp), 2);
		close(fileno(fp));

	
		char dot_slash[] = "./";
		char *dsPtr = dot_slash;
		strcat(dsPtr, file_name);
		puts(dsPtr);
	
		char *arg[1];
		arg[0] = NULL;	
		//arg[1] = NULL;
	
		execve(dsPtr, arg, NULL);

thanks

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by gerard4143
0

hm . . . so if my cgi file which opens up html templates, that means that execve() will run the cgi file (which it does) but the html templates the cgi file runs will come out as text and not code.

0

hm . . . so if my cgi file which opens up html templates, that means that execve() will run the cgi file (which it does) but the html templates the cgi file runs will come out as text and not code.

Here's my 'limited' understanding of CGI. A client requests something from a web server, the web server runs CGI script/executable which formats a html web page which is then beamed over to the web client who then views/accepts it in a web browser....

Edited by gerard4143: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.