title: Execute a concatenation command with execvp
body: <p>How can I execute the following command using execvp, if it's possible:</p>
  
  <blockquote>
    <p>"ls | tee ~/outputfile.txt"</p>
  </blockquote>
  
  <p>I've tried to run the following code but got this message: execvp() not expected: No such file or directory
  I'm not sure for the cause of this issue,
  I can't execute this command because this is concatenation command ?</p>
  
  <pre><code>#include &lt;unistd.h&gt; // execvp()
  #include &lt;stdio.h&gt;  // perror()
  #include &lt;stdlib.h&gt; // EXIT_SUCCESS, EXIT_FAILURE
  
  
  int main(void) {
  char *const cmd[] = {"ls | tee ~/outputfile.txt", NULL};
  execvp(cmd[0], cmd);
  perror("Return from execvp() not expected");
  
  exit(EXIT_FAILURE);
  }
  </code></pre>
  
  <p>In the bottom line, want to write the output of the command 'ls' to a file in my code.</p>
  
  <p>Thank you in advance!</p>