This is a discussion on Shell Creation - Unix Tutorial ; i wrote this shell given below. please i need any suggestions and assistance in making this created shell support the following commands: cp (copy), del (delete), hos (prints the hostname of the machine), cd (changes directory), clr (clears the screen), ...
i wrote this shell given below. please i need any suggestions and assistance in making this created shell support the following commands: cp (copy), del (delete), hos (prints the hostname of the machine), cd (changes directory), clr (clears the screen), dir (lists contents in directory), environ(lists the environment setting), echo (displays comment followed by a new line), help (displays the help associated with my shell) and quit ( exits the shell). please would be very grateful anyones attention shown too this. thank you
char buf ;
char *args ;
*prompt for and read a command.
if (gets (buf) == NULL)
* Split the string into Arguments.
parse (buf, args);
* Execute the command.
} // endof for loop
/* parse -- Splits the command in buf into individual arguments */
parse (buf, args)
while (*buf != NULL)
*Strip White Spaces. Use Nulls, so
*that the previous argument is terminated automatically
while ((*buf == ' ') || (*buff == '\t'))
*buf++ = NULL;
/* Save the Argument. */
*args++ = buf;
/* Skip over the argument. */
while ((* != NULL) && (*buf != ' ' ) && (*buf != '\t'))
/* execute -- spawns a child process and execute the program */
/* Get a child process */
if ((pid= fork()) <0)
/* NOTE. perror() produces a short error message on the standard
error describing the last error encountered during a call to a
system or library function */
* The Child executes the code inside the if
if (pid == 0)
execvp (*args, args);
/* NOTE. The execv() and execvp versions of execl() are useful when the number
of arguments are unknown in advance:
The arguments to execv() abd execvp() are the name of the file to be executed
and a vector of strings containing the arguments. The last argument string must
be followed by a 0 pointer.
execlp() and execvp() are called with the same arguments as execl() and execv(),
but duplicate the shell's actions in searching for an executable file
?* The parent executes the wait. */
while (wait (&status) !=pid)