I have made a custom java program to output a license and am trying to run it in php.
$deviceid="12345";
$command_app = 'java -jar /home/myname/secure/mycommand.jar开发者_运维问答 ';
$privateKey = 'QEFAASCAmEwggJdAgE';
$command_app_args = "\"$privateKey\" deviceid=$deviceid";
$command=$command_app.$command_app_args;
$license = shell_exec($command);
The problem is that $license is empty every time, I tried to print out the $command using
echo $command;
and then ran that command directly in the linux terminal and the xml output was correct.
I am using
System.out.println()
in the java app to print all the xml output. I tried something simple like
shell_exec('ls -l') ;
and sure enough if worked.
What might I be doing wrong?
My first instinct is that the command java is not in PHP's shell path. Try something like this:
$command_app = '`which java` -jar /home/myname/secure/mycommand.jar ';
The command which java
will return the full path to the java executable...
精彩评论