-6

i am trying to create a shell using C as a homework but my execvp() doesnt work . it doesnt exe the ls. i am working at a virtual machine lubuntu 32 Thas my outpout any my error message ! http://prntscr.com/6um9xm

if(pid==0){        
       printf("child");                                                                                                            
  char **tokens=tokenizer(hey)//hey is from fgets. tokenizer is fine
printer(tokens);

  //execute ls                                                                                                                                                               
  execvp( ls_args[0], ls_args);

  //only get here if exec failed                                                                                                                                             
  perror("execv failed");

  return 2; //return error status   }
Andrea Corbellini
  • 17,339
  • 3
  • 53
  • 69
Panos
  • 77
  • 1
  • 7

1 Answers1

1

Your third argument (a[2]) has a newline character at the end. ls thus complains that it can't find a directory named with a single newline character under your home directory. Fix your command parsing to not include the newline.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98