I am trying to develop a Shell Emulator and using Jsch for the same. I am trying to open a shell session but I am not able to read the input stream from the Shell session. I am using the following code.
JSch jsch = new JSch();
Session session;
session = jsch.getSession(username, server, port);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking", "no");
session.connect(30000);
Channel channel=session.openChannel("shell");
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
int SIZE = 1024;
byte[] buf=new byte[SIZE];
while(true)
{
buflen=in.read(buf, bufs, buf.length-bufs);
if(buflen<=0){
buflen=0;
throw new IOException("fillBuf");
}
System.out.println(buflen);
}
But no output is coming. What am I doing wrong?