All pastes #113105 Raw Edit

fork gahhhh

public text v1 · immutable
·published 2006-08-03 11:16 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/wait.h>

int main()
{
	int ans;
    int ret;
	char **argv;
	char *temp;
	char command[100];
	argv = malloc(sizeof(char)*2);
    
	printf("\n****** My shell starts here ******\n");
	printf("\n");
	printf("myBash$> ");
	char **enviro = '\0';
	
	while(1)
	{	
	   /*Read command and other agruments from stdin*/	
		
		fgets(command,100,stdin);
		
		temp = (argv[0] = strtok(command," \t\n"));
	
		
		if(temp != NULL)
		{
		 /*if input is exit*/
		 if(strcmp("exit",argv[0]) == 0)
		 {
		     break;
		 }
	    
        execve("/bin/ls",argv,enviro);
       }
	printf("myBash$> ");
	}

return 0;
}