Hi!
(firstly : sorry for my english, i posted my problem in a french forum but i diddn't found any answer )
So:
I have to make a shell in a server.
The client has to connect to the server, ask some tasks to the server, the server has to resolve the task and then give the result to the client.
The solution:
I redirected stdout and stderr to the client, then when the client ask someting to the server, the server use execvp and then the client read the stdout of the execvp.
The problem :
Some tasks (like chmod) doesn't have any output.
With those tasks, i have a big problem : The client waits a message from the server, but he receives nothing !
I can't post my code because it's for the school, but i can show some importants parts of it :
this is the main part of my client-Socket:
server :Code:
- fgets(requete,250,stdin);
- while (strcmp(task,"exit\n" )){
- write(sd,task,250);
- read(sd,ligne,taille);
- printf(ligne);
- fgets(task,250,stdin);
- }
with the others tasks (like "echo hello world" everything works fine).Code:
- while(condition) {
- i=0;
- tokens[i]=strtok(ligne," \n" );
- while (tokens[i] != NULL) tokens[++i]=strtok(NULL," \n" );
- if (fork()==0)
- {
- fflush(stdout);
- execvp(tokens[0],tokens);
- fflush(stdout);
- printf("invalid task\n" );
- exit(1);
- }
- wait(0);
- read(h, ligne, strlen(ligne));
- }
- }
Sorry again for my english, and thanks for helping