簡體   English   中英

Java - JSch - 獲取退出狀態 123. 這是什么意思?

[英]Java - JSch - Getting exit status 123. What does it mean?

運行命令從遠程服務器上的文件中檢索數據(代碼如下)。 在關閉頻道時,有時會收到退出代碼 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.*"

退出代碼是系統特定的。

您可能正在連接到 *nix 系統。 所以你可能想閱讀答案
在 find + xargs grep 中得到退出代碼 123

123 表示“任何以非零狀態退出的調用”。


強制性警告:不要使用StrictHostKeyChecking=no盲目接受所有主機密鑰。 這是一個安全漏洞。 你失去了對MITM 攻擊的保護。 有關正確(且安全)的方法,請參閱:如何在使用 JSch SFTP 庫時解析 Java UnknownHostKey?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM