php exec java发送到ttyUSB0

我需要运行一个java jar,通过php </ p>
来创建与设备ttyUSB0的连接 n

如果我使用此命令从shell运行它,则jar文件正常工作</ p>

  java -jar rxtx.jar'param_to_send'
</ code> </ pre >

使用参数send to device和“ok”输出结果</ p>

现在我必须从php执行此操作,经过几次试验,我得到的命令似乎正常工作 </ p>

  $ output = param_to_send; 
exec(“/ usr / bin / java -jar rxtx.jar'”。$ output。“'2&gt;&amp; 1”,$ 输出);
</ code> </ pre>

输出将返回“ok”,但在我的设备上没有连接... </ p>

也尝试过 shell_exec和exec具有sudo / root权限,但结果相同...... </ p>
</ div>

展开原文

原文

I need to run a java jar that create connection to a device ttyUSB0, through php

The jar file work correctly if I run it from shell with this command

java -jar rxtx.jar 'param_to_send'

with parameter send to device and "ok" output result

Now I must execute this from php and after several trials, I get this command that seems works correctly

$output = param_to_send;
exec("/usr/bin/java -jar rxtx.jar '".$output."' 2>&1" , $output);

the output will return "ok", but on my device no connection...

Tried also with shell_exec and exec with sudo/root privileges, but same result...

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐