0
下面的代码无法使用ssh2_exec获取Java版本,我尝试了绝对路径/ usr/bin/java,同样的代码正在使用'php --version',这个问题的可能原因是什么?php ssh2_exec未执行java命令
已经做搭配chmod 777的/ usr/bin中/ JAVA
$connection = ssh2_connect('xx.xx.xx.xx', 22);
ssh2_auth_password($connection, $username, $password);
$stream = ssh2_exec($connection, 'java -version;');
stream_set_blocking($stream, true);
$tempVar = stream_get_contents($stream);
echo $tempVar; // nothing printed here
尽管分号不是问题,如果我使用 $ tempstream = ssh2_fetch_stream($ stream4,SSH2_STREAM_STDERR); 然后输出进入$ tempstream,使用STDDIO时它会发出警告。仍然不确定这里发生了什么,但我的要求已经实现。 – siso