#9 Execution sometimes returns false exitcode

open
nobody
None
5
2004-08-02
2004-08-02
Anonymous
No

When executing a remote command twice, the second
result may contain a false exitcode of -1

e.g.
public void test() {
Session session = jsch.getSession("root", "test",
"127.0.0.1");
session.setPassword("test");

session.setUserInfo(new MyUserInfo(127.0.0.1,
"root","test"));

session.connect();

Channel channel = session.openChannel("exec");
ChannelExec c = (ChannelExec) channel;
c.setCommand("/bin/rpm -qa");

ReadStream out = new ReadStream(c.getInputStream());
ReadStream err = new ReadStream(c.getErrStream());

channel.connect();
while (!channel.isEOF());
System.out.println(channel.getExitStatus());
}

public static void main (String[] args) {
test();
test();
}

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks