I’m trying to launch a CLI command from a PHP script:
in particular I wanna use this command convert a.png a.tif to convert an image to tiff.
When I launch this command from CLI it works as expected but if I launch from a PHP script with the following code it doesn’t create any tiff image in my folder:
$exec = "convert a.png a.tif";
exec($exec,$yaks,$err);
echo "<pre>";
print_r($yaks);
echo "$err";
echo "</pre>";
Moreover $yaks is empty and $err is set to 127.
I’m not an expert, why this doesn’t work as expected?
Best regards
UPDATE
I used this command instead $exec = "convert 4.png 4.tif 2>&1"; and I got in return [0] => sh: convert: command not found
This seems to me strange since I can use it from CLI!
FINAL UPDATE
Thanks a lot guys!
$exec = "/usr/local/bin/convert a.png a.tif";
This command solved the problem!
You’re great.
you should enter fullpath to “convert” and may be files.
err 127 – file not found