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

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

main ()
	char buf [1024];
	char *args [64];

	for (;;)
	 *prompt for and read a command.
	printf ("Command:");

	if (gets (buf) == NULL)
	printf ("\n");
	exit (0);

	 * Split the string into Arguments.
	parse (buf, args);

	 * Execute the command.
	execute (args);
	} // endof for loop

/* parse -- Splits the command in buf into individual arguments */
parse (buf, args)
char *buf;
char **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'))
	*args= NULL;

/* execute -- spawns a child process and execute the program */
execute (args)
char **args;
	int pid,status;

	/* Get a child process */

	if ((pid= fork()) <0)
	{	{
	exit (1);
	/* 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);
	perror (*args);
	exit (1)

/* 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
environment. */

   ?* The parent executes the wait. */
	while (wait (&status) !=pid)
	 /*empty */

7 Years
Discussion Span
Last Post by Salem

> i wrote this shell given below.
I very much doubt it. I've seen the basic outline many times before.
It looks like boilerplate homework for you to fill in the blanks of your assignment yourself.


okay is it possible too push me in the right direction. hoping thats not to much of assistance

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.