Below scripts working fine in CMD window but not in browsers. Below scripts are in 'front.php', win10's command window command 'php front.php' doing nice but http://localhost/blahblah/front.php
sucking me by not triggering 'back.php'. Spent almost half a night trying all possibilites include shell_exec
, proc_open
but all ending up with above issue. Basic permission, php.ini related issues are all taken care.
pclose(popen('powershell.exe "Start-Process php -ArgumentList \'back.php\' -WindowStyle Hidden"','r'));
echo exec('D:\Wamp\php\php.exe D:\Wamp\apache2\htdocs\MySite\admin\back.php > output.txt 2>&1 echo $!', $pid);
Update
Just to narrow down, I'm using Win 10 Admin user and all WAMP setup is in my local pc only, using PHP 5.6.x. Both front.php and back.php are in same working folder and front able to write to file but back.php not executed from browser. From CMD the same is working!
front.php:
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
file_put_contents('timelog.txt', date('Y-m-d/H:i:s.u'));
echo exec('php back.php > output.txt 2>&1 echo $!');
// pclose(popen('powershell.exe "Start-Process php -ArgumentList \'back.php\' -WindowStyle Hidden"','r'));
?>
back.php:
<?php
sleep(5); // some delay
file_put_contents('timelog.txt', date('Y-m-d/H:i:s.u'). "\n");
?>