[英]Ganymed SSH2 JAVA, tips: Command not found
Ganymed ,execCommand("java -version") Tips:bash: java: command not found But I use Shell tool, i can get the java version。 the ganymed can't get the local environmental variables? Ganymed,execCommand(“ java -version”)提示:bash:java:命令未找到但是我使用Shell工具,可以获取Java版本。ganymed无法获取本地环境变量? How can i do it?
我该怎么做?
The reason for this problem is the lack of environmental variables. 该问题的原因是缺乏环境变量。 You can try the following code to solve.
您可以尝试以下代码来解决。
public void execNoReturnRemoteCommand(String command, long timeout)
throws Exception {
Connection conn = getConnection();
Session session = null;
try {
session = conn.openSession();
session.requestPTY("bash");
session.startShell();
PrintWriter out = new PrintWriter(session.getStdin());
out.println(command);
out.println("exit");
out.close();
session.waitForCondition(ChannelCondition.CLOSED | ChannelCondition.EOF | ChannelCondition.EXIT_STATUS, timeout*1000);
} finally {
if (session != null) {
session.close();
}
if (conn != null) {
conn.close();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.