I´m trying to run the following code, but it doesn´t work. I just want to execute a program, when the input name of the programm is done. I don´t know where the problem really is, cauze the code seems ok. Maybe there are other important things, that I did not notice...
setbuf(stdout, NULL);
char input[255];
char path[255];
int status;
char *args[2] = {"ls", NULL};
while(strcmp(input, "end") != 0 ){
printf("Waiting for input:\n");
scanf("%s",input);
strcpy(path, "./");
strcat(path, input);
if(strcmp(input, "end") != 0){
printf("execute %s\n", path);
int ret = execv(path, args);
if(ret == -1){
perror("execve error");
}
}
else{
printf("Programm-Ends\n");
}
};
return 0;