lundi 2 mars 2015

php exec() not working with windows environment variables

I am trying to run a couple commands from PHP with exec() and it seems to work only for some of the commands defined in my windows environment variables but not for all.

In my command prompt I can run all of this commands succesfully from any path (C:\ or E:\whatever)



> pear -V // ... "PEAR Version: 1.9.5" ...
> dot -V // dot - graphviz version 2.38.0 (20140413.2041)
> phpdoc -V // phpDocumentor version 2.8.1


All of them return the correct version for each of the specified programs, that means that the environment variables are well configured.

But in PHP I can only run this command for pear, the rest of them fails:



$out = array();
$ret = '';

exec('pear -V', $out, $ret);
echo var_dump($out); // $ret = 0, $out = array ..."PEAR Version: 1.9.5" ...

exec('phpdoc -V', $out, $ret);
echo var_dump($out); // $ret = 1, $out = array ..."Could not open input file: \phpdoc" ...

exec('dot -V', $out, $ret);
echo var_dump($out); // $ret = 1, $out = empty array


So, am I missing something?.


Aucun commentaire:

Enregistrer un commentaire