I need to get completion variants for Linux commands using PHP function exec(). I try this:
$c = exec('compgen -c pyt');
I except getting something like this
python3.5m
python3.5
python2.7
python2
python3
python3m
python
But instead I get an error:
sh: 1: compgen: not found
When I execute this command directly in terminal output is correct:
omix@omix:~$ compgen -c pyt
python3.5m
python3.5
python2.7
python2
python3
python3m
python
I also tried using function shell_exec() but it didn't work.
Finally I have solved this. I found out that I use different shells in my terminal session and when running PHP exec() (or shell_exec()) function:
Now I run shell commands from PHP like this:
This works for me.