troubleshooting Question

Calling shell_exec shows weird behavior from php

Avatar of Sreejith22
Sreejith22Flag for India asked on
LinuxJavaPHP
14 Comments1 Solution630 ViewsLast Modified:
Following php code works and I get output:

<?php

echo 'hello world';
echo shell_exec('ls -la');

?>

// Output
hello worldtotal 2064 drwxrwxrwx. 3 root root 4096 Jul 4 10:26 . drwxr-xr-x. 4 root root 4096 Jul 4 10:17 .. -rw-rw-r--. 1 arun arun 2089447 Jul 3 11:09 cakephp-cakephp-2.3.6-0-gd10df32.zip -rw-r--r--. 1 root root 32 Jun 18 18:01 info.php drwxrwxrwx. 7 arun arun 4096 Jul 3 12:23 nykkos -rw-r--r--. 1 arun arun 76 Jul 4 10:26 test.php

The following code does not work:

<?php

echo 'hello world';
echo shell_exec("java -jar /var/www/html/nyk/app/webroot/Converter.jar $id");

?>

It just shows a blank white screen. Even the simple java -version when used in the above php code gives a blank screen. Even the 'hello world' does not get printed.

Whereas the java commands discussed above work without any issues from terminal. My OS is fedora. It works fine in ubuntu!!

What is the reason behind this strange behaviour and how can I overcome the same?

Any help is much appreciated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros