I am not able to figure out whether a command has completed its execution or not before sending the next command using the JSch library in Java.
Code snippet
// Opens a new channel of type 'exec'
Channel channel = sesConnection.openChannel("exec");
// sets the command to be executed
((ChannelExec) channel).setCommand(command);
// Gets an input stream for this channel
InputStream commandOutput = channel.getInputStream();
channel.connect();