I am running a Java program on a web server and passing it arguments that come from PHP variables, and I'm running into a bit of a confusing issue. A Java program I am using seems to exhibit different behavior when I run it from shell and run it from shell_exec() in with PHP.
If I use a tool like Putty to execute the program from command line like so:
ksh runexample.ksh ClassName methodName
It runs properly, meaning the program sends a request and after about 20 seconds receives a response from gateway servers it connects to. I am then able to see that the communication was successful by seeing the resulting record in an outside database.
Now the issue arises when I execute this program from a PHP script by using.
shell_exec('path/ssh user@xxx.xx.xxxx.xx.x "cd /path/path/examples/ ksh runexample.ksh ClassName methodName;')
If I load this PHP script, and var_dump() the output, the program seems to load; but it gives me a short generic message from the Java program like "program running in connected mode etc etc", and doesn't output the usual response. The PHP script loads a page almost instantly with this output. Also, no record is created in the outside database.
I have set_time_limit(0) in the script, but could this issue be due to shell_exec() somehow timing out before the request/response in the Java program is complete?
Thanks for any insight/similar experiences, I appreciate the help!