PHP exec not work on PHP 7.2.34

nitiphone2021

New member
Hi all.

I tried to execute command below
` echo '<br/>'.$data. " >=> " . exec("java -jar encrypt.jar ".$data." ".$privateKey, $key);`
it's look like we run `java -jar encrypt.jar 192.168.101.1BBB10052 ssdsds`
I can run this command on the server by ssh but when I use PHP code, it's nothing.
so I need to enale the exec function or different command on this version?
 
Seem only java command can't run
Code:
echo "linux = '" . exec("ls -l") . "'";
echo "<br>java = '" . exec("/usr/bin/java -version") . "'";


Code:
[root@host ~]# which java
/usr/bin/java
[root@host ~]#

Code:
[root@host ~]# java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
[root@host ~]# 
[root@host ~]# 
[root@host ~]# 
[root@host ~]# /usr/bin/java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
[root@host ~]# .

I can run it on command line but why PHP can't execute it?
 
Copy this to script.php:

Code:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo shell_exec('java --version');

What do you get if you run that?
 
Now I can exec the command.
my point is
1. exec command not allow on php.ini
2. on PHP can't call java command by "java" need to put full location
3. path of jar file, my PHP file and java file in the path but I can't call it like javafile.jar need to put full path.
`exec("/usr/bin/java -jar /home/public_html/believe.com/CoVaF/func/encrypt.jar `

Thank you for support
 
Back
Top