I want to use php\'s exec() function on an ubuntu server. The problem is, I alway get an error, that the command is not found. For example using
exec(\"echo
I think PHP calls /bin/sh internally (or cmd.exe on Windows) regardless of which function you use.
Running ls -l /proc/$$/exe | sed 's%.*/%%' in your terminal in a Linux system should tell you what shell you're using, which is bash in my Ubuntu terminal by default. If you run the following in Ubuntu:
you will get ["dash"] as the result, regardless of which function you use. If you change /bin/sh to point to bash rather than dash, the result from PHP changes to bash, but I don't recommend doing that obviously.
So long story short it's probably not possible to change this without modifying your entire server's default shell or compiling PHP from source.
If you want to solve the mystery further, it's probably related to ext/standard/proc_open.c and ext/standard/exec.c (all these functions are in there, system, passthru, etc.) in the PHP source, but to be honest it beats me.