Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/312788-php-exec-not-work-on-php-7234/
Share on other sites

:psychic:

Is exec() enabled? Can you run other commands? Simple commands?
Is the command exactly what you think it is? You've confirmed $data and $privateKey have the values you think they have?
Are you executing this from the right directory? Do commands like is_file() think that "encrypt.jar" exists where you expect?

Now I enable it but seem I can't run only java

       
echo "linux = '" . exec("ls -l") . "'";
echo "<br>java = '" . exec("/usr/bin/java -version") . "'";
       

Linux command can work but java not work

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

I tried like this but not work

[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 ~]# 

 

Updated!!!!!

Updated!!
Now I can execute java command like java -version
but can't execute jar file

 echo exec("/usr/bin/java -version 2>&1",$output); // Output work
echo "<br>";
echo exec("/usr/bin/java -jar encrypt.jar ".$data." ".$privateKey . " 2>&1",$key);

Result:

OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
Error: Unable to access jarfile encrypt.jarArray ( [0] => Error: Unable to access jarfile encrypt.jar )

In the same command, I can run it on my laptop can work properly

the file encrypt.jar permission is 777

Back to one of the questions I asked earlier: are you sure PHP is running from the correct location? Does glob/scandir/ls without any path information include encrypt.jar? Are file permissions correct such that Apache and/or PHP can properly access the file?

In other words, does

var_dump(is_readable("encrypt.jar"));

output true?

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 all for support 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.