I haven't used execvp() before, but after a little looking around, it seems that you supply several arguments to it in a list which will result as, when executed, argv[0], argv[1] etc. So, in other words, you are supposed to split up your string by the token " " into an array, then pass the first item to the first argument of execvp(), then the rest to the second. This array must be terminated with a null pointer.
Code:
char cmd[] = "/bin/ls /home/nuticulus/ -l";
char **toks;
int c=0;
printf("Running %s\n",cmd);
toks = (char**) malloc(sizeof(char*));
toks[0] = (char*)strtok(cmd," ");
while(toks[c]!=NULL)
{
printf("#%d %s\n",c+1,toks[c]);
c++;
toks = (char**) realloc(toks, (c+1)*sizeof(char*));
toks[c] = (char*)strtok(NULL, " ");
}
execvp(toks[0], toks); That would split the string cmd into an array of character pointers, delimited by a final NULL pointer.