1

Running command to retrieve a data from files on remote server (code bellow). On closing channel sometimes receiving exit code 123.

Found in https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

ERROR_INVALID_NAME 123 (0x7B) The filename, directory name, or volume label syntax is incorrect.

But I am not sure it is the same error code meaning. Please, advise

Code:

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
    }
}

Connecting to Linux. Running command like:

find filesPath -type f -name "meAutomation,meAutomation*"| xargs egrep -r -i "20171031(04|03).*,meAutomation,meAutomation,.*,mEnterprise.*"
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Lubov Shilin
  • 133
  • 2
  • 10

1 Answers1

0

The exit code is system specific.

You are probably connecting to *nix system. So you may want to read answers to
Got exit code 123 in find + xargs grep.

123 means "any invocation exited with a non-zero status".


Obligatory warning: Do not use StrictHostKeyChecking=no to blindly accept all host keys. That is a security flaw. You lose a protection against MITM attacks. For the correct (and secure) approach, see: How to resolve Java UnknownHostKey, while using JSch SFTP library?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks, I believe it is it. Just left to understand what in my command can cause non-zero status :) I'm afraid this is the answer : The exit code will still be 123 if there are grep invocations which return zero matches – Lubov Shilin Oct 31 '17 at 14:40