I can run about any binary but not that composer.phar using PHP's exec
or shell_exec
.
In the same folder I have composer and another php executable with same permissions:
ls -lh
total 1,8M
-rwxr-xr-x 1 me me 1,8M août 22 20:48 composer.phar
-rwxr-xr-x 1 me me 39 août 22 21:05 test.php
Test.php contains:
#!/usr/bin/env php
<?php
print 'hello';
I then have this script:
<?php
print $cmd = "composer.phar --version 2>&1" ;
print "<br>";
$return = exec( $cmd );
var_dump($return);
print "<br><br>";
print $cmd = "test.php 2>&1";
print "<br>";
$return = shell_exec( $cmd );
var_dump($return);
Here is what I get:
composer.phar --version 2>&1
[...]Process.php:81:string 'sh: 1: : Permission denied' (length=26)
test.php 2>&1
[...]Process.php:88:string 'hello' (length=5)
Why do I get that string 'sh: 1: : Permission denied'
error? I tried executing in PHP with /usr/bin/env php composer.php
/usr/bin/php composer.php
, I get the same error.