I have to make a custom shell as a school project and I'm hitting a wall with this:
int exec_shell(char **argv) //
{
if (execve(argv[0], (char **)argv , NULL)==-1) //if an error occurs
{
printf("Commande invalide : %s\n", argv[0]);
fflush(stdout);//vide le buffer
exit(0);
return -1;
}
return 0;
}
It's supposed to be very simple - you put in a command in string form and exec calls the said command. However, it always returns an error.
What am I doing wrong?
Here is the single warning:
primitives.c:25:30: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]