title: How to execute an interactive command from PHP?
body: <p>I need to execute <em>kdiff3</em> command in my desktop machine (localhost) from PHP script (using browser, not command line). I've given permission for the user <em>www-data</em> that is executing the scripts to execute kdiff3 using <em>visudo</em>. In fact, if I log in as <em>www-data</em> I can execute it without problems (<em>sudo kdiff3 ...</em>, it's configured to not ask for a password at all). </p>
  
  <p>The problem is when I try to execute this command from a PHP script. I've tried this:</p>
  
  <pre><code>$output = shell_exec("sudo kdiff3 -m $file.def.old $file $file.def -o $file");
  </code></pre>
  
  <p>and nothing happens (output is NULL). If I try a non interactive command, like <em>ls</em> it works:</p>
  
  <pre><code>$output = shell_exec("ls");
  </code></pre>
  
  <p>What's happening? Why cannot execute an interactive command?</p>