[JSch-users] Exec channel session hanging on disconnect
Status: Alpha
Brought to you by:
ymnk
From: bode o. <bod...@ho...> - 2005-10-05 17:28:10
|
I'm execing a command via ssh and reading an error response using getErrStream. However, it seems to hang .Any ideas please? try{ channel=session.openChannel("exec"); ((ChannelExec)channel).setCommand(command); ((ChannelExec)channel).setErrStream(System.err); err = ((ChannelExec)channel).getErrStream(); InputStreamReader istreamreader = new InputStreamReader(err); BufferedReader breader = new BufferedReader(istreamreader); String error= ""; channel.setInputStream(System.in); channel.connect(); while(true) { if(channel.isClosed()) { if ((error = breader.readLine()) != null) { throw new Exception(error); } break; } } } catch(Exception ex) {} finally{ try { channel.disconnect(); err.close(); breader.close(); istreamreader.close(); } catch(Exception e){} } |