26 lines
994 B
C
26 lines
994 B
C
|
/*************************************************************/
|
|||
|
/* demo_exec_arg : */
|
|||
|
/* - Reservation de la place max des arguments */
|
|||
|
/* (20 car.), */
|
|||
|
/* - 1er param<61>tre = la commande a executer, */
|
|||
|
/* - 2<>me param<61>tre et suivant = param<61>tres de */
|
|||
|
/* la commande */
|
|||
|
/* - execution (avec prise en compte de la */
|
|||
|
/* variable PATH). */
|
|||
|
/*************************************************************/
|
|||
|
#include <stdio.h>
|
|||
|
#include <unistd.h>
|
|||
|
int main (int argc, char* argv[])
|
|||
|
{
|
|||
|
char* argv2[argc];
|
|||
|
int i;
|
|||
|
printf(" argc=%i \n", argc);
|
|||
|
for (i= 1; i <= argc; i++)
|
|||
|
{
|
|||
|
argv2[i-1] = argv[i];
|
|||
|
printf(" argv[%i] = %s\n", i, argv2[i-1]);
|
|||
|
}
|
|||
|
execvp (argv2[0],argv2);
|
|||
|
printf ("\nERREUR : execvp impossible\n");
|
|||
|
}
|