title: PHP: run shell_exec or system as sudo?
body: <p>I have a few commands I need to invoke from my PHP web application that can only run as <code>sudo</code>.</p>
  
  <p><a href="http://php.net/manual/en/function.shell-exec.php" rel="nofollow">http://php.net/manual/en/function.shell-exec.php</a> says (in the comments) that I can do the following:</p>
  
  <pre><code>system('echo &lt;password&gt; | sudo -u root -S &lt;command&gt;');
  </code></pre>
  
  <p>It doesn't work. I'm trying to do a <code>groupadd</code>, <code>useradd</code>, etc. Suggestions? </p>