Linux / UNIX Tech Support Forum
This is a discussion on Help with execvp function in C program ! within the Coding in General forums, part of the Development/Scripting category; I knew that execvp exec a child process with its argument list. Code: int main () { /* The argument ...
|
|||||||
| Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I knew that execvp exec a child process with its argument list.
Code:
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;
}
Code:
phpPATH=/usr/local/bin/php scriptPATH=/usr/local/apache/htdocs/myweb/myscript.php Code:
char* arg_list[] = {
“phpPATH”,
“scriptPATH”,
“scriptArgument”,
NULL /* The argument list must end with a NULL. */
};
----------------
execvp(phpPATH,arg_list)
Thanks in advanced ! |
| Sponsored Links | ||
|
|
|
||||
|
Is it Linux or any other UNIX box? Also, do you get any specific error code or message? For further debugging try
PHP Code:
__________________
Vivek Gite Linux Evangelist Last edited by nixcraft; 17-06-2009 at 12:08 AM. |
|
||||
|
Here is my test.c
PHP Code:
PHP Code:
Code:
./test
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| c program , execvp , execvp replaces the calling process , gcc , linux , unix |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fattach function which package | sathiya | Linux software | 2 | 02-06-2008 05:41 PM |
| Adding storage function to a mail server | satimis | Databases servers | 0 | 04-01-2008 01:15 PM |
| is any one good in c program ? | oronno | Shell scripting | 0 | 19-09-2007 01:04 PM |
| start program | schaapmansz | Getting started tutorials | 1 | 26-06-2007 09:49 PM |
| call function in bash | mala_un | Shell scripting | 9 | 18-08-2006 01:36 AM |