I have a problem running the exec command from within a php script.
here's the detailed scenario:
I have an executable my_exe which runs from command line. This executable uses an environment variable, so I prepend the command with
MY_VARIABLE='value'
(works fine).I use the exec command to run this executable from a Php script. ex:
exec("MY_VARIABLE='value' my_exe");
(works fine too, tested in a browser)The problem is in this part. When I call the php script from a Java program using HttpUrlConnection, I have two cases: if I run the Java program from outside the server (using public IP address) I get the good results, but when I run it from the server (using local IP, form command line ex. "
java -jar /path/to/my/jar
"), the Php works but the exec doesn't seem to be working properly. The environment variable is not being set in this case, so the executable runs but without the right values, so I get no results.
Any help is appreciated. I'm really stuck here. My guess is that there is a problem with Php or Java permissions, but I can't figure it out.