I am trying to execute a shell script (which is in a different unix server). Now i have seen that sometimes it was unable to execute that script. As that script takes very long time to execute, therefore i cannot read/wait for the output. just wanted to make sure that the script has ran every time.
JSch jsch = new JSch();
String cmd="cd /blackduck/tfs/tfsconnector; ./runTFSConnector_web ;
session = jsch.getSession("UserID", hostIP, 22);
session.setUserInfo(new SSHUserInfo("Password"));
session.connect();
channel = session.openChannel("exec");
((ChannelExec)channel).setCommand(cmd);
channel.connect();
while((!channel.isClosed()){
Thread.sleep(3000);
}
I have added the while loop just b'coz of channel to be closed.
Kindly give some solution. any suggestion will be highly appreciable.