-
problem
Code:
while(1) {
char cmd[20];
printf("Shell: "); scanf("%s",&cmd);
res = fork();
if(res==0) {
if((strcmp("ls",cmd))==0) { execl("/bin/ls","ls",NULL); insert_list(list, "ls"); }
if((strcmp("ps",cmd))==0) { execl("/bin/ps","ps",NULL); insert_list(list, "ps"); }
if((strcmp("historic",cmd))==0) { Print_list(list); }
}
else {
wait(&status);
}
}
}
iīm creating a little shell, and each time i execute a command i want it to
be saved in a linked list, so when i execute the command historic, it prints the commands i had executed before. But when i execute command historic the list donīt print nothing. I think it is because execl, because if i take the instruction execl("/bin/ls","ls",NULL); it prints the list with the elements correct, in this case ls.
Sorry about the English.
-
How about continuing with the same thread, rather than starting a new thread with a new approach to the same problem.
http://cboard.cprogramming.com/showthread.php?t=70498
People will rapidly start to ignore you if you don't engage in a conversation and just keep posting new threads in the hope that someone will post a solution in response.