&1 '; $res = shell_exec($cmd)" /> &1 '; $res = shell_exec($cmd)" /> &1 '; $res = shell_exec($cmd)"/>

Php Shell_exec not works in php 7.3.8 but not in 7.4.33

132 Views Asked by At

I have this code :

 $urlfile=dirname(__FILE__)."/test.php value1 value2 "; 
 $cmd = 'nohup nice -n 10 php -f '.$urlfile.' 2>&1 ';
 $res = shell_exec($cmd);
 echo $res;

It executes a file php by a shell_exec placed in another php file.

I have two macs with two MAMP versions. In Mac A i have mamp 5.5 with php 7.3.8 , in Mac B i have mamp 6.8 with php 7.4.33

The code above works fine in Mac A , but if i run it in Mac B it returns an error :

nice: php: No such file or directory

It seems that 'php:' it's considered as a part of the file path.

  • The file hierarchy is the same form Mac A and Mac B
  • I have checked php.ini and shell_exec function is activated in Mac B.

Why i can't run on Mac B ? Maybe it depends on php version ?

0

There are 0 best solutions below