I knew that execvp exec a child process with its argument list.
But if I want to execute my shell or php script in execCode:int main () { /* The argument list to pass to the “ls” command. */ char* arg_list[] = { “ls”, /* argv[0], the name of the program. */ “-l”, “/”, NULL /* The argument list must end with a NULL. */ }; pid_t child_pid; /* Duplicate this process. */ child_pid = fork (); if (child_pid != 0) /* This is the parent process. */ return child_pid; else { /* Now execute PROGRAM, searching for it in the path. */ execvp (ls, arg_list); fprintf (stderr, “an error occurred in execvp\n”); abort (); printf (“done with main program\n”); return 0; }
I've failed withCode:phpPATH=/usr/local/bin/php scriptPATH=/usr/local/apache/htdocs/myweb/myscript.php
How can I use execvp with my own script ?Code:char* arg_list[] = { “phpPATH”, “scriptPATH”, “scriptArgument”, NULL /* The argument list must end with a NULL. */ }; ---------------- execvp(phpPATH,arg_list)
Thanks in advanced !

Reply With Quote
