![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Executing shell program from a web page | venkatritch | Shell Programming and Scripting | 5 | 06-14-2008 02:36 AM |
| Advantage of executing program in user shell? | seeker333 | UNIX for Advanced & Expert Users | 2 | 05-21-2008 11:19 AM |
| after executing execvp()... program hangs up | Crab | High Level Programming | 3 | 09-21-2006 07:31 AM |
| Executing an .ec program in different informix versions | matrixmadhan | High Level Programming | 0 | 05-21-2005 03:29 AM |
| executing the su command from a java program. | shailendrat | UNIX for Dummies Questions & Answers | 1 | 03-24-2005 08:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
executing a program within a program
Read the title: how do i do it?
__________________
Go to my site... Download my Winamp3 skin... enjoy the beauty... |
| Forum Sponsor | ||
|
|
|
|||
|
fork/execv in CGI
I'm having a couple of problems with my CGI program.
First, I don't know how to get [the text our getfacl program would create] back so I can return it to a web browser. I was hoping that, since getfacl program writes to standard output, that it would just be written back to the browser (or to standard output) when called from within the hello.cgi program. Secondly, the fork command doesn't seem to work the same for a CGI program. When I call the program from the prompt (it's called hello.cgi), everything comes out as expected... Code:
bash-2.05$ ./hello.cgi Content-type: text/html waiting<br> calling getfacl<br>called getfacl<br>done waiting<br> Code:
Content-type: text/html calling getfacl<br>called getfacl<br>Content-type: text/html waiting<br> done waiting<br> So, my two questions are:
By the way, I guess I should mention that it's running through apache 1.3.20 on red had linux. Wish I knew how to get the Linux version, but... Although I understand the concepts fairly well, I've got almost no experience with fork or the exec family (and only a little UNIX/Linux experience), The hello.cgi code is below. Any help would be greatly appreciated. Code:
#include <stdio.h>
int main (int argc, char *argv[])
{
int result,stat;
char *args[]={"getfacl", ".", 0};
printf("Content-type: text/html\n\n");
if (fork()) {
printf("waiting<br>\n");
result=wait(&stat);
printf("done waiting<br>\n");
} else {
printf ("calling getfacl<br>");
execv ("getfacl", args);
printf ("called getfacl<br>");
exit(-1);
}
printf ("\n");
return 0;
}
|
|||
| Google The UNIX and Linux Forums |