title: shell_exec returns NULL but when tried from console, it works
body: <p>I have three php scripts. One, I start with init script. The second is started by the first one itself and the second then uses <code>shell_exec</code> to get output from the third script by passing various params to it periodically.</p>
  
  <p>But it's not happening. When I <code>var_dump</code> the output of <code>shell_exec</code>, in the second script, I get <code>NULL</code>. But when I print the actual command which is used in <code>shell_exec</code> in the second script and try entering it into console, it works very well!</p>
  
  <p>I tried the command from console of same user with which I start the init script.</p>
  
  <p>This might be a permission issue. But I have the proper permissions setup i.e.</p>
  
  <ol>
  <li>+x for the third script</li>
  <li>the third script (actually all the three are) is owned by the same user and group I use the console with</li>
  </ol>
  
  <p>Note - I tried starting the third script with shebang as well as by removing the shebang and adding <code>php</code> before the script path. With root everything runs fine.</p>
  
  <p>Also, just another note, the first script redirects output of the second script to a log file (this is where I found the third script returning <code>NULL</code> on <code>shell_exec</code>)</p>
  
  <p>UPDATE: The code from second script which uses <code>shell_exec</code></p>
  
  <pre><code>$command = "/var/data/user-data.php '{$user}' '{$request['token']}' '{$request['secret']}'";
  $data = json_decode( shell_exec( $command ), true );   
  </code></pre>
  
  <p>I tried printing <code>$command</code> and also <code>var_dump( shell_exec( $command ) )</code>. The former one returns what is expected (the params) and the latter returns NULL</p>