How to create one's own pipe in one's own shell?

[LEFT]Good evening, I'm trying to do my own shell and I encountered some issues while creating it. Indeed when I try such a command I have

DAUPHINE> DAUPHINE> ls -l | grep terminal > fichier 
DAUPHINE> cat fichier

[/LEFT]

My shell is named DAUPHINE
Whereas I should have:

Code:

coppan12@b042-12:~$ ls -l | grep terminal > fichier coppan12@b042-12:~$ cat fichier 
-rwxr-xr-x 1 coppan12 student   13765 d�c.  18 15:18 terminal

I did in a function called commande that activate a parsing function that looks for delimiters and creates an array mot with the other words:

Code:

DAUPHINE> DAUPHINE> ls | pwd
/users/coppan12

It actually doesn't show the ls command
Have you any idea of how to fix it?

  1. The problem statement, all variables and given/known data:

From the following parsing function, I had to create my own shell.
It was given from my teacher, I don't perfectly understand how it works but I did it but the pipe and the redirection with the pipe.

void parsing(){     int i=0;     int cmot=0;     while(1){         c = getchar();         if      (c == '\n') {symboleP = 0;return;}         else if (c == ';')  {symboleP = 1;return;}         else if (c == '&')  {symboleP = 2;return;}         else if (c == '<')  {symboleP = 3;return;}         else if (c == '>')  {symboleP = 4;return;}         else if (c == '|')  {symboleP = 5;return;}         else if (c == EOF)  {symboleP = 7;return;}         else if (c != ' ') {             symboleP = 10;             while(c != '\n' && !strchr(delimiteurs,c)){                 i=0;                 while(c != 32 ){                     if((c != '\n') && !strchr(delimiteurs,c)){                     mot=c;i++;                     c=getchar();                     }                     else {break;}                 }                 break;             }             while(c == ' ')             {                 c=getchar();             }             ungetc(c,stdin);             mot=0;             respP[cmot++]=strdup(mot);             fflush(stdout);             if(c == '\n' || strchr(delimiteurs,c))             {                 respP[cmot]=0;                 return;             }         }     }  }

Right then, there is my own function commande, which I created myself, I didn't shown the variables to make it lighter and shown the 0 case:

  1. Relevant commands, code, scripts, algorithms:

simple UNIX commands
close, dup, fork, open...

  1. The attempts at a solution (include all code and scripts):

I tried:

void commande () {     while(1){         if(execute==1){             if(symboleP==0){                 printf("DAUPHINE> ");             }                 for (j=0;j<10;j++){                 respP[j]=NULL;             }                         execute=0;                 background=0;         }         fflush(stdout);         parsing();         switch (symboleP) {// which are initialized above by the parsing             case 0 :                            // SYMBOLE : \n                 p=fork();                  if(p==0){                    //fils                     if(tube==1){//printf("\n\n\n");                               fich = open("fichtmp",O_RDONLY,0640);                         close(0); //fermeture clavier                         dup(fich); //fichier devient entr�e 0                         execvp(respP[0], respP);                         close(fich); //fermeture fichier                           }                           else if(output==0 && input==0){        //pas de redirection                           printf("truc1");                         execvp(respP[0], respP);                            } ... other code over there ask me if needed ...

Okay, right actually the pipe doesn't work when I do

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Paris IX
Paris
France
Michel
Unix et programmation Unix