#include #include #include #include #include #include #include int main() { char **newargv; char *temp; char command[100]; extern char **environ; newargv = malloc(sizeof(char)*2); printf("\n****** My shell starts here ******\n"); printf("\n**********************************\n"); printf("myBash$> "); /*Read command and other agruments from stdin*/ while(fgets(command,100,stdin) != NULL && (printf("myBash$> ") != -1)) { pid_t child; temp = (newargv[0] = strtok(command," \t\n")); child = fork(); if(temp != NULL) { /*if input is exit*/ if(!strcmp("exit",newargv[0])) { free(newargv); exit(0); } if(child == 0) { execve("/bin/ls",newargv,environ); } } } free(newargv); return 0; }