I am trying to run a script de php
in the background.
Command execution works fine on the production server Linux
, but not on the development serverWindows
I have the following code:
I verify in which server we are this returns LIN
orWIN
$sistema = strtoupper(substr(PHP_OS, 0, 3));
Address of the script to execute
$direccion = RAIZ."/admin/proyectos/generar.php";
Now I run the command:
LINUX (works fine)
if($sistema == "LIN"){
exec("php ".$direccion . " Nproyect=".$Nproyect . " Temail=".$Temail. " > /dev/null 2>&1 &");
}
WINDOWS (not working)
if($sistema == "WIN"){
pclose(popen("start /B php ".$direccion . " Nproyect=".$Nproyect . " Temail=".$Temail , "r"));
}
Target File - Currently I just get the variables and print them to a txt but later it will do a pretty big process.
<?php
if ($_SERVER["DOCUMENT_ROOT"]=="") $_SERVER["DOCUMENT_ROOT"]= "/var/www/vhosts/tacktil.com/httpdocs";
include $_SERVER["DOCUMENT_ROOT"]."/php/lib.plib";
parse_str($argv[0], $params);
$argv = preg_replace("//");
$smg = "el proyecto es " . $Nproyect . " el correo es ". $Temail;
file_put_contents("prueba.txt",$smg);
?>