|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
need help with simple shell program
i am have a problem with my program i don't know how to correct my errors. here's the program
and errors: #include <stdio.h> #include <iostream.h> #include <sys/types.h> #include <sys/wait.h> void parse(char *line, char **argv) { argv[0] = (char *)malloc (100); argv[1] = (char *)malloc (100); argv[2] = NULL; int counter = 0; while(*line != '\0') { char *temp_val = argv[counter]; while((*line != '')&&(*line != '\t')&&(*line != '\n')&&(*line != '\0')) { *(temp_val++) = *(line++); } *temp_val = '\0'; counter ++; while((*line == '' || *line == '\t' || *line == '\n')&&(*line != '\0')) { line++; } } } int main() { char line[100]; char *argv[100]; while(1) { cin.getline(line,100); parse(line, argv); if strcmp(argv[0], "exit")==0) exit (0); { int childpid; childpid = fork(); if(childpid > 0) { waitpid(childpid,0,0); } if (childpid ==0) { execvp(argv[0],argv); } } return 0; } parse error before '(' token that does this mean? |
|
#2
|
|||
|
|||
|
that 'simple shell program' will mostly called a 'c-program'
(i can|will not read it) ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > need help with simple shell program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|