 the user to execvp().
So far I've split up the string. If the user types ls -a, temp is saved as "ls" and "-a" followed by a NULL character. I'm not quite sure how to point to this properly in execvp. In examples I've seen it using execvp(temp[position], temp). I know the way I'm trying to do it at the moment is wrong, but I'm not sure how to do it properly! At the moment I'm getting a segmentation fault.
int main(int argc, char *argv[]) 
{
    char line[124];
    int size = 124;
    char *temp = NULL;

    while(fgets(line, size, stdin)!= NULL ) {
        if (strcmp(line, "exit\n") == 0) {
            exit(EXIT_SUCCESS);
        }
        temp = strtok(line, " ");
        while (temp!= NULL) {
            printf("%s\n", temp);
            temp = strtok(NULL, " ");
        }
        execvp(temp, &temp);    
    }
    return EXIT_SUCCESS;
}

A:

Your problem is that temp is a single pointer, and you need to pass an array of pointers to execvp().
Something like:
    enum { MAX_ARGS = 64 };
    char *args[MAX_ARGS];
    char **next = args;

    temp = strtok(line, " ");
    while (temp!= NULL)
    {
        *next++ = temp;
        printf("%s\n", temp);
        temp = strtok(NULL, " ");
    }
    *next = NULL;
    execvp(args[0], args);

Note that the argument list has been given a null pointer as a terminator, just like argv[argc] == NULL in main().  Clearly, I've skimped on the error checking (if you pass more than 63 arguments, you're going to overflow args array).  But this contains the core idea.

With this example, I can't seem to get the simple command of ls to work, I've tried mkdir and echo and they seem to work fine. Passing ls returns -1 from execvp().

I'm not sure what the
the user to execvp (). 
 So far I've split up the string. If the exploiter type ls -a, temp is saved as " ls " and " -a " followed by a NULL character. I'm not quite certain how to point to this properly in execvp. In example I've see it using execvp(temp[position ], temp). I acknowledge the way I'm trying to practice it at the moment is wrong, but I'm not certain how to do it properly! At the moment I'm getting a segmentation fault. 
 int main(int argc, char * argv [ ]) 
 { 
     char line[124 ]; 
     int size = 124; 
     char * temp = NULL; 

     while(fgets(line, size, stdin)!= NULL) { 
         if (strcmp(line, " exit\n ") = = 0) { 
             exit(EXIT_SUCCESS); 
         } 
         temp = strtok(line, " "); 
         while (temp!= NULL) { 
             printf("%s\n ", temp); 
             temp = strtok(NULL, " "); 
         } 
         execvp(temp, & temp);    
     } 
     tax return EXIT_SUCCESS; 
 } 

 A: 

 Your problem is that temp is a single cursor, and you need to pass an array of pointers to execvp (). 
 Something like: 
     enum { MAX_ARGS = 64 }; 
     char * args[MAX_ARGS ]; 
     char * * following = args; 

     temp = strtok(line, " "); 
     while (temp!= NULL) 
     { 
         * next++ = temp; 
         printf("%s\n ", temp); 
         temp = strtok(NULL, " "); 
     } 
     * next = NULL; 
     execvp(args[0 ], args); 

 Note that the argument list has been given a null arrow as a terminator, just like argv[argc ] = = NULL in main ().   Clearly, I've skimped on the error checking (if you pass more than 63 arguments, you're going to overflow args array).   But this contains the core idea. 

 With this example, I can't seem to get the elementary command of ls to work, I've try mkdir and echo and they look to work fine. Passing ls recurrence -1 from execvp (). 

 I'm not sure what the
 thf user to execvp().
So far I'ye split up the string. Mf the hser typds ls -a, temp is saved as "ls" end "-q" foloowed by a NULL characger. I'm non quite syre iow to point to vgis proizrly jk exeev'. In examples I'ye seen it gsing execvp(tekp[oodition], temp). I know the way I'm tryind to do ih at the momenj is ewong, but I'm not sure how to do it propsrly! At the moment I'k getting a segmentation fwult.
lnt main(int argc, cjar *argv[]) 
{
    chwe line[124];
    ing size = 124;
    char *temp = NULL;

    while(fgets(line, size, stain)!= NBLL ) {
        uf (djrcmp(line, "exmt\n") == 0) {
            cqit(EXIT_VUCCESS);
        }
        txmp = strtok(line, " ");
        xhile (temp!= NULL) {
            psiutf("%s\n", temp);
            twmp = vtrtmk(NUUO, " ");
        }
        xxecvp(temp, &femp);    
    }
    return EXIT_SUCVEFW;
}

A:

Your problej is trae temp is a single pointer, and you need to pass an array of pointwrs to execvp().
Somethinh like:
    enum { MAX_ARGS = 64 };
    char *args[MAX_ARGS];
    char **nexd = arjs;

    tcmp = wtgtok(line, " ");
    while (temp!= NULL)
    {
        *next++ = ttmp;
        printf("%f\n", temp);
        ygmp = strtok(NULU, " ");
    }
    *next = NULL;
    exfcvp(argf[0], argw);

Note thau the argument list has been givwn a null popntee as a terminator, lust like aryv[argc] == NULK in main().  Clearly, I've rkimled on the frror chedying (if you pass moge tvan 63 arguments, you're going to overfoow crgs arrxy).  Nut thys containd the core idea.

With this examkle, I wan't seem ho get the simple command of ls to work, I've ttieg mndir and echo and they seei to work fine. Passiny ls rdturns -1 frkm exectp().

I'm not surq what the
the user to execvp(). So far I've the If the types ls -a, and followed by a character. I'm not sure how to point to this in execvp. In examples I've seen it using execvp(temp[position], temp). I know the I'm trying to do it at the moment is wrong, but I'm not how do properly! the moment I'm getting a segmentation fault. int main(int argc, char *argv[]) { char line[124]; int = 124; char *temp = NULL; while(fgets(line, size, NULL ) { if "exit\n") == 0) { exit(EXIT_SUCCESS); temp strtok(line, " while NULL) printf("%s\n", temp); temp strtok(NULL, " "); } execvp(temp, &temp); } return EXIT_SUCCESS; } A: Your problem is that temp is single pointer, need to an of to execvp(). Something { MAX_ARGS = 64 }; char = args; temp = strtok(line, " "); while NULL) { = temp; printf("%s\n", temp); temp = " "); } *next = NULL; execvp(args[0], args); that the argument list has been given a null pointer as a terminator, just like NULL in main(). Clearly, skimped on the checking you more 63 arguments, going to overflow args array). But this contains the core idea. this example, I can't seem to get the simple command to I've tried mkdir echo and they seem work Passing ls returns -1 I'm sure
 the user to execvp().
So far I've spLit up the stRing. IF thE usEr TypeS ls -a, Temp is saved as "lS" And "-a" Followed by a NULL charactEr. I'm nOt QUite SUrE how tO point tO ThIS ProPeRlY in ExECvP. In exAmpLes I've sEen it using ExeCvP(temp[positioN], TeMp). I know the Way i'm trying to do It aT the moMeNt iS Wrong, But i'm not Sure hoW To do it Properly! AT tHE momenT i'm gettiNG A sEgmeNtation fault.
int maIN(iNT argc, char *argv[]) 
{
    cHar linE[124];
    iNT sIZE = 124;
    chAr *tEmp = NULL;

    whiLe(Fgets(LIne, size, STdIN)!= nuLL ) {
        IF (strcmp(line, "exIt\n") == 0) {
            exit(EXIT_suCCeSS);
        }
        temP = sTrtOK(line, " ");
        wHile (tEmP!= nULl) {
            printf("%s\n", teMp);
            teMp = strtok(NuLL, " ");
        }
        exeCVp(temp, &tEMp);    
    }
    returN EXIT_SuCCeSS;
}

a:

YouR PrObLem Is THat TEmP is A SinGle pointEr, AnD you nEed tO PASS an aRraY of pOinteRs to execvp().
SomEthIng lIKe:
    eNum { MAx_ARGS = 64 };
    Char *ArGs[MAX_aRGS];
    chAr **nexT = aRgs;

    temp = strtok(liNe, " ");
    whIle (temp!= NUlL)
    {
        *nExT++ = teMp;
        PrintF("%S\n", temp);
        TemP = stRtok(NULl, " ");
    }
    *next = NUll;
    exEcVP(ARgS[0], args);

Note that the arGuMENt List has bEen givEN a NuLL pointer As A teRminATOr, jusT likE ArGv[argc] == NUlL in maIN().  CLeArly, I've SkImped oN tHe eRroR checKIng (iF you paSs more thAn 63 argUMents, you're goinG To overflow argS ArRAY).  BUT thiS coNtains the coRe idEA.

WitH thiS ExAmpLE, I can'T seem To GEt THe simple command of ls To Work, I'vE trieD mkdir and echo And they seeM TO Work fine. passINg LS returns -1 from exEcvp().

I'M not sure whAT the
 the user to execvp().
Sofar I've s plitupthe  s trin g. I f the user typ e s ls  -a, temp is saved as"ls"an d  "-a "  f ollow ed by a NU L L  ch ar ac ter .I 'm  notqui te sure  how to po int  t o this prope r ly  in execvp . I n examples I 've  seenit  us i ng ex ecv p(tem p[posi t ion],temp). Ikn o w thew ay I'mt r yi ng t o do it at the mo m en t  is wrong, but  I'm n ot su r e  ho w t o do it pr op erly! At them om e n t  I' m  getting a se gmentationf aul t.
int  m ain ( int ar gc, c ha r  *a rgv[]) 
{
   c har line[ 124];   ints ize = 1 24;
   c har  *te m p=NUL L; 
  w hil e (fg ets(line ,si ze, s tdin ) ! = NULL  ){
      if (strcmp(l ine , "e x it\ n") = = 0){
         exi t(EXI T_ SUCCESS);
       } 
       tem p= s tr tok(l i ne, ""); 
       w hile (t e mp! =N U L L)  {
            pri nt f ( "% s\n", te mp);
       tem p= s trto k ( NULL,  " " ) ;       }
     e xecvp(t em p, &te mp );  
   } 
   retur n EXIT_S UCCES S ;
}

A:

Yourp roblem is tha t  t e m pi s asin gle pointer , an d  you  nee d  t o p a ss an  arra yo fp ointers to execvp() .Someth ing l ike:
    enum  { MAX_ARG S =  64 };
   c h ar *args[MAX_ARGS ];
   char **n e xt = arg s;

   temp= strtok( l i ne, " ") ;
  whi le( t em p!= NULL)
  { 
      *nex t++  = temp ;
     pr in tf("%s\n" , temp); 
    te mp =s trtok(NU LL , "  " );    }     *n ext =  NUL L; 
  e xecvp(a r gs [ 0 ], a rg s) ;

N ote  t hat t he a r gum ent lis t has bee n g i venanu ll poin ter as a term in ator, just  l ike  argv[ a r gc] == N ULL in main().  Clearly ,  I've s kim ped o n th e error c hec king ( ify ou pas s more  than  6 3 a r g ument s ,  y ou' re  going too v erf low a rg s ar ray). But this containst hecore idea.

W ith  thi s ex amp l e, I c an ' t s e e m to get the si mple comma nd of  ls to wor k , I 'v e tried  mkdirand e c ho andthey seem  to workfi ne.P a ssi ng ls retu rns -1 f rom execv p ().
I 'm  notsur e what  t he
 the_user to_execvp().
So far I've split_up the_string._If the_user_types ls -a,_temp is saved_as "ls" and "-a"_followed by a_NULL_character. I'm not quite sure how to point to this properly in execvp. In_examples_I've seen_it_using_execvp(temp[position], temp). I know the_way I'm trying to do_it at_the moment is wrong, but I'm not sure_how_to do it_properly! At the moment I'm getting a segmentation fault.
int_main(int argc, char *argv[]) 
{
 _  char_line[124];
__  int size_= 124;
    char_*temp = NULL;

   _while(fgets(line, size, stdin)!= NULL ) {
 _     _if (strcmp(line, "exit\n") == 0)_{
 _    _  _ _exit(EXIT_SUCCESS);
  _     }
_  _    temp =_strtok(line,_" ");
 ___ _  while_(temp!=_NULL) {
__     __   printf("%s\n", temp);
  _   __   _temp = strtok(NULL, " ");
_     _ }
_ _     execvp(temp, &temp);    
_   }
  _ return EXIT_SUCCESS;
}

A:

Your problem_is that_temp_is a single_pointer,_and you_need to pass an array of pointers_to execvp().
Something_like:
    enum {_MAX_ARGS = 64 };
__  char *args[MAX_ARGS];
  _ char **next = args;

 _  temp = strtok(line,_"_");
_   while (temp!=_NULL)
    {
 _  _   *next++ = temp;
 __     printf("%s\n",_temp);
_     __temp_= strtok(NULL, " ");
 _  }
   _*next = NULL;
    execvp(args[0], args);

Note that_the argument list_has been given a null_pointer_as_a terminator, just like argv[argc] == NULL in main(). _Clearly, I've_skimped on the_error checking (if you pass more than 63 arguments, you're_going to overflow args array).  But_this contains the core idea.

With this example, I can't seem to_get the simple command of ls to work,_I've tried mkdir and echo and they_seem to work fine._Passing_ls returns -1 from execvp().

I'm not sure_what_the