title: How does execvp run a command?
body: <p>I know <code>execvp</code> can be used to execute simple commands as follows:</p>
  
  <pre><code>char* arg[] = {"ls", "-l", NULL};
  execvp(arg[0],arg);
  </code></pre>
  
  <p>I want to know what goes on in here when I run <code>execvp</code>. In man page it says <code>execvp</code> replaces the image of the process image with the new one. However here I am running a command not an executable. </p>
  
  <p>To be specific, say there is a command that specifically requires an input e.g. cat. If I have a text file text.txt which contains the file name expected for cat and I redirect stdin to the file stream of the file, would the output of <code>execle("cat","cat",NULL)</code> or <code>execvp("cat", arg)</code> (obviously where arg stores <code>"cat"</code> and <code>NULL</code>) result in the output in the console as the <code>cat /filename</code> would? My intuition is I have to read the file and may be parse it to store the arguments in the arg. However I want to make sure.</p>
  
  <p>Thanks in advance!</p>