0

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.

Shibankar
  • 806
  • 3
  • 16
  • 40
  • You say that "sometimes it was unable to execute that script". What happens in this case? How do you know? Did you get any error messages? What did they say? – Kenster Aug 01 '14 at 12:29
  • @Kenster Its not throwing any error message at all. but in my unix server i can see the script was not executed. Is there any way to confirm that the script has ran successfully or reattempt if it is fail. – Shibankar Aug 04 '14 at 05:40
  • @Kenster And also some times i have seen that channel.getExitStatus() != 0 . means channel is not getting closed properly. – Shibankar Aug 04 '14 at 06:02

0 Answers0