title: execve - No such file or directory?
body: <p>I'm having some problems with execve. I'm trying to make a shell that can function just like the bash shell, but I have problems with the forked child executing a command. Here is what I have for the child. cmd is a char * with the command that the user typed in. However, when I run this program, I get this error from perror:</p>
  
  <pre><code>execve error: No such file or directory.
  </code></pre>
  
  <p>I have tried the program with a simple ls, and it should make path="/bin/ls" and execute it (I have confirmed this is where my ls command is) but it still complains. What am I doing wrong? Thanks!</p>
  
  <pre><code>if(pid == 0)
  {
      // Parse the command
      char * word = strtok(cmd, " ");
      char path[128] = "/bin/";
      strcat(path, word);
  
      // Execute the process
      char * newenvp[] = { NULL };
      char * newargv[] = { path, NULL };
      ret = execve(path, newargv, newenvp);
  
      if(ret == -1)
          perror("execve error");
  
      return EXIT_SUCCESS;
  }
  </code></pre>