【发布时间】:2018-04-11 09:32:08
【问题描述】:
运行命令从远程服务器上的文件中检索数据(代码如下)。 在关闭频道时,有时会收到退出代码 123。
发现于https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
ERROR_INVALID_NAME 123 (0x7B) 文件名、目录名或卷 标签语法不正确。
但我不确定它是相同的错误代码含义。 请指教
代码:
JSch jsch = new JSch();
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session = jsch.getSession(BillingUser, BillingHost, 22);
session.setPassword(BillingPassword);
session.setConfig(config);
session.connect();
channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
channel.setInputStream(null);
(ChannelExec) channel).setErrStream(System.out);
InputStream inputStream = channel.getInputStream();
InputStream errStream = channel.getExtInputStream();
channel.connect();
if (inputStream.available() > 0) {
//saving output here
}
inputStream.close();
errStream.close();
if (channel.isClosed()) {
if (channel.getExitStatus() != 0){
//printing here exitStatus value
}
}
连接到 Linux。运行命令如下:
find filesPath -type f -name "meAutomation,meAutomation*"| xargs egrep -r -i "20171031(04|03).*,meAutomation,meAutomation,.*,mEnterprise.*"
【问题讨论】:
标签: java shell ssh jsch exit-code