I'm working on a simple shell for my school project and atm I am trying to pass two input paramaters to be used with a command (ex: ls /home/ -l) as I can only pass 1 atm. Meaning whatever goes after "/home/" doesn't get executed. I've tried this to solve it, but it doesn't and I have no idea what to do.
EDIT: sorry this line was only meant to visualise what are these variables: pid = fork() , char* = arg[30] , char = input .
if(pid != 0) {
waitpid(-1, &stat, 0) ;
}
else {
if(arg[2]!=0) {
char* doubleArgument = (char *) malloc(1 + strlen(arg[1])+ strlen(arg[2]) ) + 1;
strcpy(doubleArgument, arg[1]) ;
strcpy(doubleArgument, " ") ;
strcpy(doubleArgument, arg[2]) ;
execvp(input, doubleArgument) ;
}
else {
execvp(input, arg) ;
printf("Error detected at: %s\n", strerror(errno)) ;
exit(-1) ;
}
What should I do? For any advice - thank you :)