PHP命令shell_exec()无法用于我的自定义Java应用程序5 [英] PHP command shell_exec() not working for my custom Java app5

查看:37
本文介绍了PHP命令shell_exec()无法用于我的自定义Java应用程序5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个自定义Java程序来输出许可证,并试图在php中运行它.

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);

问题是$ license每次都是空的,我尝试使用

The problem is that $license is empty every time, I tried to print out the $command using

echo $command;

,然后直接在linux终端中运行该命令,并且xml输出正确.

and then ran that command directly in the linux terminal and the xml output was correct.

我正在使用

System.out.println() 

在Java应用程序中

打印所有xml输出.我尝试了

in the java app to print all the xml output. I tried something simple like

shell_exec('ls -l') ;

足够肯定是否可行.

我可能做错了什么?

推荐答案

我的第一个直觉是java命令不在PHP的shell路径中.尝试这样的事情:

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 ';

命令哪个java 将返回Java可执行文件的完整路径...

The command which java will return the full path to the java executable...

这篇关于PHP命令shell_exec()无法用于我的自定义Java应用程序5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆