title: Starting an application on the server using php
body: <p>I have web server that publishes a web page with an image viewer and a "Start Acquisition" button.</p>
  
  <p>On the server, I have a small application that looks like this: <code>./cgi-bin/ccss -d GenericUSBCamera ...</code> with several more parameters. My application belongs to <em>root / root</em>.</p>
  
  <p>In the web page, I use AJAX to start the app. Here is a snippet of the code for the <code>onclick</code> associated with the button:</p>
  
  <pre><code>&lt;script&gt;
  function startCapture()
  {
      var xmlhttp = new XMLHttpRequest();
      xmlhttp.open( "GET", "cgi-bin/start-capture.php?t=" + new Date().getTime(), true );
      xmlhttp.send()
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Once the <code>send()</code> is done, I assume a message is sent to the server and the <code>start-capture.php</code> script is launched. Actually, it is because if I tweak the above JavaScript function and I modify <code>start-capture.php</code> to send back a <code>echo</code> I receive it correctly.</p>
  
  <p>But the actual <code>start-capture.php</code> is:</p>
  
  <pre><code>&lt;?php
  exec( '/var/www/cgi-bin/ccss -d GenericUSBCamera...' );
  ?&gt;
  </code></pre>
  
  <p>and nothing happens when we click the button. But I know the script is lauchned because if I get the return message in my JavaScript function, it is correct. But, as I said, my application <code>ccss</code> doesn't do anything. Actually it is supposed to grab from a USB camera and save images in the folder /var/www/images. Notice that all scripts/applications on server have all rights to execute and even when I start the app by hand on the server, everything is fine.</p>
  
  <p>What I would like to do is what should I do to start such an application with parameters with PHP? I'm new to PHP and I'm a little confused with <code>exec()</code>, <code>shell_exec()</code>, etc...</p>
  
  <p>Somebody has an idea?</p>
  
  <p>Thanks in advance!</p>