We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use exec to execute the command, execute it in large concurrency, and block on the stream for a period of time
logger.info(new StringBuilder(this.ip).append(",执行输出命令:").append(command).toString()); try (InputStream stdout = openChannel.getInputStream()) { openChannel.connect(); long startTime = System.currentTimeMillis(); byte[] tmp = new byte[1024]; while (true) { while (stdout.available() > 0) { int i = stdout.read(tmp, 0, 1024); if (i < 0) break; result.append(new String(tmp, 0, i, Charset.defaultCharset())); } if (openChannel.isClosed()) { if (stdout.available() > 0) continue; break; } // 超时 if (System.currentTimeMillis() - startTime > timeout) { throw new TimeOutException("sh命令执行超时:" + command); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Use exec to execute the command, execute it in large concurrency, and block on the stream for a period of time
logger.info(new StringBuilder(this.ip).append(",执行输出命令:").append(command).toString());
try (InputStream stdout = openChannel.getInputStream()) {
openChannel.connect();
long startTime = System.currentTimeMillis();
byte[] tmp = new byte[1024];
while (true) {
while (stdout.available() > 0) {
int i = stdout.read(tmp, 0, 1024);
if (i < 0)
break;
result.append(new String(tmp, 0, i, Charset.defaultCharset()));
}
if (openChannel.isClosed()) {
if (stdout.available() > 0)
continue;
break;
}
// 超时
if (System.currentTimeMillis() - startTime > timeout) {
throw new TimeOutException("sh命令执行超时:" + command);
}
}
The text was updated successfully, but these errors were encountered: