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

I always understood that's what its supposed to do...generate web script or pages.

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.

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....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.