从PHP应用程序运行PHP CLI脚本

I have a php file which needs to be executed in CLI from my Php application which runs on CodeIgniter framework. I tried the exec and shell_exec command and it seems to not start the process. Please find the code below which I try to execute.

$phpPath = exec('which php');
$cmd = $phpPath.' '.dirname(__DIR__).'/API/notification/NotificationServer.php';
echo "<pre>".shell_exec($cmd)."</pre>";

When I try running the above in Terminal it executes fine. I need to automatically trigger this once the user has a session set.

The path/$cmd variable prints

when I print the variable $cmd i get the below output, and the below when given in terminal works fine.

/usr/bin/php /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php

the above command works fine in the Terminal. When i try to exec/shell_exec it, it is not working.

APACHE_ERROR LOGS ARE :

sh: line 1:  2437 Trace/BPT trap: 5       /usr/bin/php
sh: line 1: /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php: Permission denied

Can someone help me out in running this above code in CLI ?

I solved the problem, Guess there would be someone else like me trying to access the restricted folders. I found the solution here

http://ubuntuforums.org/showthread.php?t=1302259

exec('chmod +x'.dirname(__DIR__).'/API/notification/NotificationServer.php);

The above worked the magic.