use of com.jcraft.jsch.ChannelExec in project ignite by apache.
the class StartNodeCallableImpl method exec.
/**
* Gets the value of the specified environment variable.
*
* @param ses SSH session.
* @param cmd environment variable name.
* @return environment variable value.
* @throws JSchException In case of SSH error.
* @throws IOException If failed.
*/
private String exec(Session ses, String cmd) throws JSchException, IOException {
ChannelExec ch = null;
try {
ch = (ChannelExec) ses.openChannel("exec");
ch.setCommand(cmd);
ch.connect();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(ch.getInputStream()))) {
return reader.readLine();
}
} finally {
if (ch != null && ch.isConnected())
ch.disconnect();
}
}
Aggregations