2

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();
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Sugata Kar
  • 367
  • 1
  • 10

1 Answers1

1

When executing commands, there are two sources you can use to decide if the command failed:

For an example how to read both, see How to read JSch command output?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992