/* The parser piece for the minishell assignment Replace the part that prints the parsed command with you code that does the fork, exec, wait. */ #include #include #include #include extern char **environ; int main() { int ch; char line[40]; char *nargs[10]; char *space = " "; char *where; while(1) { int i = 0; printf("Your command please: "); fgets(line,sizeof(line),stdin); line[strlen(line)-1] = '\0'; where = strtok(line,space); nargs[i++] = where; while (where != NULL) { where = strtok(NULL,space); nargs[i++] = where; } ch = getchar(); if(fork()==0) if(ch=='1') execlp("ls","ls","/usr",NULL); else execlp("ps","ps","aux",NULL); wait3(&ch,0,NULL); } } };