Im trying to execute a perl script from within a php script. I have had this working using various methods such as exec, popen and proc_open but I have a couple of issues to get around which the good old Google isnt giving me the answers to.
I need to run the .pl script (passing one variable to the script which is a number) from within the php file but stop the php script from waiting until the .pl has finished (the .pl is likely to take 4-5 hours to run on the server). Im not expecting any return output from the perl script (the perl script logs its output to a mysql db) so I just need it to be running on the server and let the php script carry on.
There are some barriers to get past as its running on a Windows machines running apache, php, mysql.
I think Ive seen the solution for linux but it needs to stay on the Windows machine.
Im current trying a proc_open approach using the following code (the 35 on the proc_open line is a test id I need to pass to the perl script):
$descriptorspec = array(
0 => array("pipe","r"),
1 => array("pipe","w"),
2 => array("file","./error.log","a")
) ;
proc_close(proc_open('perl perlscript.pl 35', $descriptorspec, $pipes));
$i = 0;
while ($i < 1000) {
echo ++$i;
}
Now this code does execute the perl script but the while loop Ive placed after it (just for testing) never executes (ive not waited for the perl script to finish to see if it does) as it must be waiting for the .pl to finish.