mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
add getExitStatus check
This commit is contained in:
@@ -185,11 +185,17 @@ public class JschSession implements Session {
|
||||
channel.setInputStream(null);
|
||||
|
||||
channel.setErrStream(errStream);
|
||||
|
||||
String result;
|
||||
InputStream in = null;
|
||||
try {
|
||||
channel.connect();
|
||||
in = channel.getInputStream();
|
||||
return IoUtil.read(in, charset);
|
||||
result = IoUtil.read(in, charset);
|
||||
|
||||
if(channel.getExitStatus() != 0){
|
||||
throw new SshException("Execute command [{}] error, exit status is [{}]", cmd, channel.getExitStatus());
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
} catch (final JSchException e) {
|
||||
@@ -200,6 +206,8 @@ public class JschSession implements Session {
|
||||
channel.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user