long sessionEnd = System.currentTimeMillis();
YSLOG.info("I00002", user, host, port, privateKey, sessionEnd - sessionStart);
int exitStatus;
try {
ChannelExec channel = (ChannelExec) session.openChannel("exec");
channel.setCommand(buildCommand(commandLineTokens, environmentVariables));
channel.setInputStream(new ByteArrayInputStream(new byte[0]), true);
channel.setOutputStream(output, true);
channel.setErrStream(output, true);
YSLOG.info("I00003", user, host, port, privateKey, commandLineTokens.get(0));
long channelStart = System.currentTimeMillis();
channel.connect((int) TimeUnit.SECONDS.toMillis(60));
long channelEnd = System.currentTimeMillis();
YSLOG.info("I00004", user, host, port, privateKey, commandLineTokens.get(0), channelEnd - channelStart);
try {
while (true) {
if (channel.isClosed()) {
break;
}
Thread.sleep(100);
}
exitStatus = channel.getExitStatus();
} finally {
channel.disconnect();
}
} finally {
session.disconnect();
}
YSLOG.info("I00005", user, host, port, privateKey, commandLineTokens.get(0), exitStatus);